SockIt

NetworkThread.h

Go to the documentation of this file.
00001 /*
00002  * NetworkThread.h
00003  *
00004  *  Created on: Jun 3, 2011
00005  *      Author: jtedesco
00006  */
00007 
00008 #ifndef NETWORKTHREAD_H_
00009 #define NETWORKTHREAD_H_
00010 
00011 #include <boost/weak_ptr.hpp>
00012 #include <boost/lexical_cast.hpp>
00013 
00014 #include <map>
00015 #include <set>
00016 #include <string>
00017 
00018 #include "JSAPIAuto.h"
00019 
00020 #include "TcpClient.h"
00021 #include "TcpEvent.h"
00022 #include "TcpServer.h"
00023 #include "UdpClient.h"
00024 #include "UdpEvent.h"
00025 #include "UdpServer.h"
00026 
00027 using std::map;
00028 using std::string;
00029 
00037 class NetworkThread: public FB::JSAPIAuto
00038 {
00039     public:
00040 
00044         NetworkThread();
00045 
00049         virtual ~NetworkThread();
00050 
00058         boost::shared_ptr<TcpServer> create_tcp_server(int port, boost::optional<map<string, string> > options);
00059 
00068         boost::shared_ptr<TcpClient> create_tcp_client(const string & host, int port,
00069                 boost::optional<map<string, string> > options);
00070 
00078         boost::shared_ptr<UdpServer> create_udp_server(int port, boost::optional<map<string, string> > options);
00079 
00088         boost::shared_ptr<UdpClient> create_udp_client(const string &host, int port,
00089                 boost::optional<map<string, string> > options);
00090 
00091     private:
00092 
00096         string logger_category;
00097 
00102         void run();
00103 
00108         boost::asio::io_service io_service;
00109 
00113         boost::thread background_thread;
00114         
00116         set<boost::shared_ptr<UdpClient> > udp_clients;
00117         
00119         set<boost::shared_ptr<UdpServer> > udp_servers;
00120         
00122         set<boost::shared_ptr<TcpClient> > tcp_clients;
00123         
00125         set<boost::shared_ptr<TcpServer> > tcp_servers;
00126         
00127 };
00128 
00129 #endif /* NETWORKTHREAD_H_ */
 All Classes Files Functions Variables Typedefs Friends Defines