diff --git a/frameserver/Buffer.cpp b/frameserver/Buffer.cpp index 1431a6e..eacd457 100644 --- a/frameserver/Buffer.cpp +++ b/frameserver/Buffer.cpp @@ -3,13 +3,10 @@ Buffer::Buffer( int _id ) { id = _id; - - // allocate memory } Buffer::~Buffer() { - // deallocate memory } void Buffer::set(frame_t data) diff --git a/frameserver/Server.cpp b/frameserver/Server.cpp index c4f5633..7b86c27 100644 --- a/frameserver/Server.cpp +++ b/frameserver/Server.cpp @@ -22,6 +22,16 @@ void Server::launch_threads() 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() { int packetcounter = 0; @@ -30,13 +40,15 @@ void Server::listen() boost::asio::io_service io_service; // 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)); cout << "listening" << endl; - for (;;) + while (1) { frame_t frame; - boost::array recv_buf; + boost::array recv_buf; udp::endpoint remote_endpoint; boost::system::error_code error; @@ -80,6 +92,7 @@ void Server::listen() std::string message = "received"; boost::system::error_code ignored_error; + // we can provide feedback to clients //socket.send_to(boost::asio::buffer(message), // 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() { int size = 0; diff --git a/frameserver/defines.h b/frameserver/defines.h index 9a32e05..291a5ab 100644 --- a/frameserver/defines.h +++ b/frameserver/defines.h @@ -1,6 +1,7 @@ #ifndef __DEFINES_H_ #define __DEFINES_H_ #define BUFLEN 1024 +#define NUMBUFS 100 #define WIDTH 12 #define HEIGHT 7 #define SEGWIDTH 12 @@ -18,4 +19,4 @@ struct frame_t segment_t segments[SEGWIDTH]; }; -#endif \ No newline at end of file +#endif diff --git a/frameserver/servertest.sh b/frameserver/servertest.sh index 7994744..c95a23d 100644 --- a/frameserver/servertest.sh +++ b/frameserver/servertest.sh @@ -1,8 +1,6 @@ #!/bin/bash -i="0" - while [ 1 ] do echo "$1" | cat - display | netcat -q 0.1 -u 127.0.0.1 4321 -done \ No newline at end of file +done diff --git a/frameserver/test_server b/frameserver/test_server index b4d5db9..3811076 100755 Binary files a/frameserver/test_server and b/frameserver/test_server differ diff --git a/frameserver/test_server.cpp b/frameserver/test_server.cpp index 4914b3b..17ab338 100644 --- a/frameserver/test_server.cpp +++ b/frameserver/test_server.cpp @@ -12,10 +12,7 @@ #include "Buffer.h" #include "Buffers.h" -#define NUMBUFS 10 - using namespace std; -Buffers* buffers; int main(void) { @@ -25,7 +22,7 @@ int main(void) // our main loop with support for signals and all that jazz Glib::RefPtr Main = Glib::MainLoop::create(); - Server server(10,4321); + Server server(NUMBUFS,4321); server.launch_threads(); Main->run();