00001
00002
00003
00004
00005
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 {
00025 private:
00026 udp::socket *socket;
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
00036
00037 protected:
00038
00039
00040 public:
00041 std::deque<Message *> recBuffer;
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
00058
00059 void addMessage(Message *);
00060 Message* dequeMessage();
00061
00062 };
00063
00064 }
00065
00066 #endif