Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 20, 2009, 8:47:08 PM (15 years ago)
Author:
adrfried
Message:

some ggz things

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ggz/src/orxonox/GGZClient.cc

    r2997 r3000  
    22
    33#include <cassert>
     4#include <boost/bind.hpp>
    45
    56namespace orxonox
     
    1314        singletonRef_s = this;
    1415
    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);
    18 
    19         active = ggzmod_is_ggz_mode();
    20         if (active) {
    21             initGGZ();
    22         }
     16        initGGZ();
    2317    }
    2418
    2519    GGZClient::~GGZClient()
    2620    {
    27         if (active) {
    28             deinitGGZ();
    29         }
     21        deinitGGZ();
    3022
    3123        assert(singletonRef_s);
     
    3729        assert(singletonRef_s);
    3830        return *singletonRef_s;
     31    }
     32
     33    bool GGZClient::isActive()
     34    {
     35        return ggzmod_is_ggz_mode();
    3936    }
    4037
     
    6158        }
    6259        /* TODO: Error */
    63         ggzSocket.assign(boost::asio::ip::tcp::v4(), fd);
    64         ggzSocket.async_read_some(boost::asio::null_buffers(), handleGGZ);
     60        ggzSocket.assign(boost::asio::local::stream_protocol(), fd);
     61        ggzSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&handleGGZ, boost::asio::placeholders::error));
    6562    }
    6663
     
    7269
    7370    /* Got data from game server */
    74     void handleGame(const boost::system::error_code& /*e*/)
     71    void GGZClient::handleGame(const boost::system::error_code& /*e*/)
    7572    {
    7673        /* TODO: read from gameSocket */
     
    8885    {
    8986        ggzmod_set_state(ggzmod, GGZMOD_STATE_PLAYING);
    90         gameSocket.assign(boost::asio::ip::tcp::v4(), *(int*)data);
    91         gameSocket.async_read_some(boost::asio::null_buffers(), handleGame);
     87        getInstance().gameSocket.assign(boost::asio::local::stream_protocol(), *(int*)data);
     88        getInstance().gameSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&handleGame, boost::asio::placeholders::error));
    9289    }
    9390}
Note: See TracChangeset for help on using the changeset viewer.