listener.h

Go to the documentation of this file.
00001 /*
00002  * Listener.h
00003  *
00004  *  Created on: Jan 10, 2012
00005  *      Author: sushil
00006  */
00007 
00008 #ifndef LISTENER_H_
00009 #define LISTENER_H_
00010 
00011 #include <boost/asio.hpp>
00012 #include <boost/thread.hpp>
00013 using boost::asio::ip::udp;
00014 
00015 #include <deque>
00016 
00017 
00018 #include <messages.h>
00019 
00020 namespace FastEcslent {
00021 
00022         class Engine;
00023 
00024         class Listener { //receive update
00025         private:
00026                 udp::socket *socket;//(netService);
00027                 udp::endpoint myIP;;
00028                 int port;
00029                 bool isServer;
00030                 bool quit;
00031                 boost::thread listenerThread;
00032                 boost::mutex  quitLock;
00033 
00034                 void runThread();
00035                 // helpers
00036 
00037         protected:
00038 
00039 
00040         public:
00041                 std::deque<Message *> recBuffer; //store received messages
00042 
00043 
00044                 Listener(udp::endpoint ip, int prt, bool isserv) {
00045                         myIP = ip;
00046                         port = prt;
00047                         isServer = isserv;
00048                 }
00049 
00050                 void init();
00051                 void stop();
00052                 void join();
00053                 void run();
00054 
00055                 void kill();
00056 
00057                 //helpers
00058                 //threadsafe helpers
00059                 void addMessage(Message *);
00060                 Message* dequeMessage();
00061 
00062         };
00063 
00064 }
00065 
00066 #endif /* LISTENER_H_ */

Generated on Fri Dec 13 14:54:16 2013 for FastECSLent by  doxygen 1.5.4