minor changes
parent
6679ce8e61
commit
e1b1e41e00
|
@ -3,13 +3,10 @@
|
||||||
Buffer::Buffer( int _id )
|
Buffer::Buffer( int _id )
|
||||||
{
|
{
|
||||||
id = _id;
|
id = _id;
|
||||||
|
|
||||||
// allocate memory
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer::~Buffer()
|
Buffer::~Buffer()
|
||||||
{
|
{
|
||||||
// deallocate memory
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::set(frame_t data)
|
void Buffer::set(frame_t data)
|
||||||
|
|
|
@ -22,6 +22,16 @@ void Server::launch_threads()
|
||||||
threads.push_back( Glib::Thread::create( sigc::mem_fun(this, &Server::mix), false ) );
|
threads.push_back( Glib::Thread::create( sigc::mem_fun(this, &Server::mix), false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* this listens for UDP connections on a port and waits until there is data,
|
||||||
|
processes it and repeats */
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
error and format checking
|
||||||
|
clean exit conditions
|
||||||
|
ability for one client to take over the display
|
||||||
|
*/
|
||||||
|
|
||||||
void Server::listen()
|
void Server::listen()
|
||||||
{
|
{
|
||||||
int packetcounter = 0;
|
int packetcounter = 0;
|
||||||
|
@ -30,13 +40,15 @@ void Server::listen()
|
||||||
boost::asio::io_service io_service;
|
boost::asio::io_service io_service;
|
||||||
|
|
||||||
// next line is NOT thread-safe because we're accessing "port" without lock
|
// next line is NOT thread-safe because we're accessing "port" without lock
|
||||||
|
// however, it is done only once before any other threads are started and
|
||||||
|
// should be safe
|
||||||
udp::socket socket(io_service, udp::endpoint(udp::v4(), port));
|
udp::socket socket(io_service, udp::endpoint(udp::v4(), port));
|
||||||
|
|
||||||
cout << "listening" << endl;
|
cout << "listening" << endl;
|
||||||
for (;;)
|
while (1)
|
||||||
{
|
{
|
||||||
frame_t frame;
|
frame_t frame;
|
||||||
boost::array<char, 200> recv_buf;
|
boost::array<char, BUFLEN> recv_buf;
|
||||||
udp::endpoint remote_endpoint;
|
udp::endpoint remote_endpoint;
|
||||||
boost::system::error_code error;
|
boost::system::error_code error;
|
||||||
|
|
||||||
|
@ -80,6 +92,7 @@ void Server::listen()
|
||||||
std::string message = "received";
|
std::string message = "received";
|
||||||
|
|
||||||
boost::system::error_code ignored_error;
|
boost::system::error_code ignored_error;
|
||||||
|
// we can provide feedback to clients
|
||||||
//socket.send_to(boost::asio::buffer(message),
|
//socket.send_to(boost::asio::buffer(message),
|
||||||
// remote_endpoint, 0, ignored_error);
|
// remote_endpoint, 0, ignored_error);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +103,11 @@ void Server::listen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* the framemixer, this periodically (40 times a second) reads all input
|
||||||
|
buffers and then produces output, ready to be displayed.
|
||||||
|
In the final version, this is where interesting things will happen.
|
||||||
|
*/
|
||||||
void Server::mix()
|
void Server::mix()
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef __DEFINES_H_
|
#ifndef __DEFINES_H_
|
||||||
#define __DEFINES_H_
|
#define __DEFINES_H_
|
||||||
#define BUFLEN 1024
|
#define BUFLEN 1024
|
||||||
|
#define NUMBUFS 100
|
||||||
#define WIDTH 12
|
#define WIDTH 12
|
||||||
#define HEIGHT 7
|
#define HEIGHT 7
|
||||||
#define SEGWIDTH 12
|
#define SEGWIDTH 12
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
i="0"
|
|
||||||
|
|
||||||
while [ 1 ]
|
while [ 1 ]
|
||||||
do
|
do
|
||||||
echo "$1" | cat - display | netcat -q 0.1 -u 127.0.0.1 4321
|
echo "$1" | cat - display | netcat -q 0.1 -u 127.0.0.1 4321
|
||||||
|
|
Binary file not shown.
|
@ -12,10 +12,7 @@
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Buffers.h"
|
#include "Buffers.h"
|
||||||
|
|
||||||
#define NUMBUFS 10
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
Buffers* buffers;
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +22,7 @@ int main(void)
|
||||||
// our main loop with support for signals and all that jazz
|
// our main loop with support for signals and all that jazz
|
||||||
Glib::RefPtr<Glib::MainLoop> Main = Glib::MainLoop::create();
|
Glib::RefPtr<Glib::MainLoop> Main = Glib::MainLoop::create();
|
||||||
|
|
||||||
Server server(10,4321);
|
Server server(NUMBUFS,4321);
|
||||||
server.launch_threads();
|
server.launch_threads();
|
||||||
|
|
||||||
Main->run();
|
Main->run();
|
||||||
|
|
Loading…
Reference in New Issue