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 std::string IPAddress;
00034
00035 void runThread();
00036
00037
00038 protected:
00039
00040
00041 public:
00042 std::deque<Message *> recBuffer;
00043
00044
00045 Listener(udp::endpoint ip, int prt, bool isserv) {
00046 myIP = ip;
00047 port = prt;
00048 isServer = isserv;
00049 }
00050
00051 void init();
00052 void init(std::string ip);
00053 void stop();
00054 void join();
00055 void run();
00056
00057 void kill();
00058
00059
00060
00061 void addMessage(Message *);
00062 Message* dequeMessage();
00063
00064 };
00065
00066 }
00067
00068 #endif