Changeset 2997 for code/branches/ggz/src/orxonox
- Timestamp:
- May 20, 2009, 4:18:02 PM (16 years ago)
- Location:
- code/branches/ggz/src/orxonox
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ggz/src/orxonox/GGZClient.cc
r2889 r2997 8 8 9 9 GGZClient::GGZClient() 10 : ggzSocket(io), gameSocket(io) 10 11 { 11 12 assert(singletonRef_s == 0); 12 13 singletonRef_s = this; 14 15 boost::asio::ip::tcp::socket::non_blocking_io non_blocking_io(true); 16 ggzSocket.io_control(non_blocking_io); 17 gameSocket.io_control(non_blocking_io); 13 18 14 19 active = ggzmod_is_ggz_mode(); … … 34 39 } 35 40 41 void GGZClient::tick(const float /*dt*/) 42 { 43 boost::system::error_code ec; 44 io.poll(ec); 45 if (ec) { 46 /* TODO: Error */ 47 } 48 } 49 36 50 void GGZClient::initGGZ() 37 51 { … … 42 56 /* TODO: Error */ 43 57 } 44 int ggzSocket= ggzmod_get_fd(ggzmod);45 if ( ggzSocket< 0) {58 int fd = ggzmod_get_fd(ggzmod); 59 if (fd < 0) { 46 60 /* TODO: Error */ 47 61 } 48 sockets.add(ggzSocket, &orxonox::GGZClient::handleGGZ); 62 /* TODO: Error */ 63 ggzSocket.assign(boost::asio::ip::tcp::v4(), fd); 64 ggzSocket.async_read_some(boost::asio::null_buffers(), handleGGZ); 49 65 } 50 66 … … 56 72 57 73 /* Got data from game server */ 58 void handleGame( int fd)74 void handleGame(const boost::system::error_code& /*e*/) 59 75 { 60 /* TODO: read from fd*/76 /* TODO: read from gameSocket */ 61 77 } 62 78 63 79 /* Got data from GGZ */ 64 void GGZClient::handleGGZ( int fd)80 void GGZClient::handleGGZ(const boost::system::error_code& /*e*/) 65 81 { 66 82 ggzmod_dispatch(getInstance().ggzmod); … … 72 88 { 73 89 ggzmod_set_state(ggzmod, GGZMOD_STATE_PLAYING); 74 int gameSocket = *(int*)data;75 g etInstance().sockets.add(gameSocket, &orxonox::GGZClient::handleGGZ);90 gameSocket.assign(boost::asio::ip::tcp::v4(), *(int*)data); 91 gameSocket.async_read_some(boost::asio::null_buffers(), handleGame); 76 92 } 77 93 } -
code/branches/ggz/src/orxonox/GGZClient.h
r2889 r2997 3 3 4 4 #include "OrxonoxPrereqs.h" 5 #include "objects/ FDWatcher.h"5 #include "objects/Tickable.h" 6 6 7 7 #include <ggzmod.h> 8 #include <boost/asio.hpp> 8 9 9 10 namespace orxonox 10 11 { 11 class _OrxonoxExport GGZClient 12 class _OrxonoxExport GGZClient : public Tickable 12 13 { 13 14 public: … … 16 17 17 18 static GGZClient& getInstance(); 19 virtual void tick(const float dt); 18 20 19 21 private: … … 21 23 22 24 bool active; 23 GGZMod *ggzmod; 24 FDWatcher sockets; 25 GGZMod * ggzmod; 26 boost::asio::io_service io; 27 boost::asio::ip::tcp::socket ggzSocket; 28 boost::asio::ip::tcp::socket gameSocket; 25 29 26 30 void initGGZ(); 27 31 void deinitGGZ(); 28 static void handleGame(int fd);29 static void handleGGZ(int fd);32 void handleGame(const boost::system::error_code& e); 33 void handleGGZ(const boost::system::error_code& e); 30 34 static void handleGGZModServer(GGZMod * ggzmod, GGZModEvent e, 31 35 const void *data); -
code/branches/ggz/src/orxonox/objects/CMakeLists.txt
r2889 r2997 3 3 EventDispatcher.cc 4 4 EventTarget.cc 5 FDWatcher.cc6 5 GlobalShader.cc 7 6 Level.cc
Note: See TracChangeset
for help on using the changeset viewer.