Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 15, 2008, 10:09:02 AM (16 years ago)
Author:
scheusso
Message:

new dummy[server,client]4; adapted connectionmanager to new boost::thread syntax

Location:
code/branches/merge/src/network
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/merge/src/network/CMakeLists.txt

    r1264 r1278  
    5555  ##### end test for gamestate stuff #####
    5656ENDIF(NETWORK_TESTING_ENABLED)
     57# build this if you want dummyserver4 and dummyclient4
     58IF(NETWORKTRAFFIC_TESTING_ENABLED)
     59  ##### test network traffic #####
     60  SET( DUMMYSERVER4_SRC_FILES
     61    ConnectionManager.cc
     62    GameStateManager.cc
     63    PacketBuffer.cc
     64    PacketDecoder.cc
     65    PacketGenerator.cc
     66    ClientConnection.cc
     67    ClientInformation.cc
     68    GameStateClient.cc
     69    Server.cc
     70    Client.cc 
     71    Synchronisable.cc
     72    dummyserver4.cc
     73  )
     74
     75  SET( DUMMYCLIENT4_SRC_FILES
     76    ConnectionManager.cc
     77    GameStateManager.cc
     78    PacketBuffer.cc
     79    PacketDecoder.cc
     80    PacketGenerator.cc
     81    ClientConnection.cc
     82    ClientInformation.cc
     83    GameStateClient.cc
     84    Server.cc
     85    Client.cc 
     86    Synchronisable.cc
     87    dummyclient4.cc
     88  )
     89
     90  ADD_EXECUTABLE(dummyserver4 ${DUMMYSERVER4_SRC_FILES})
     91  TARGET_LINK_LIBRARIES( dummyserver4
     92    network
     93    ${ENet_LIBRARY}
     94    ${ZLIB_LIBRARY}
     95    ${WINDOWS_ENET_DEPENDENCIES}
     96    ${Boost_thread_LIBRARIES}
     97    core
     98    orxonoxs
     99    audio
     100  )
     101
     102  ADD_EXECUTABLE(dummyclient4 ${DUMMYCLIENT4_SRC_FILES})
     103  TARGET_LINK_LIBRARIES( dummyclient4
     104    network
     105    ${ENet_LIBRARY}
     106    ${ZLIB_LIBRARY}
     107    ${WINDOWS_ENET_DEPENDENCIES}
     108    ${Boost_thread_LIBRARIES}
     109    core
     110    orxonoxs
     111    audio
     112  )
     113ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)
     114
    57115IF(BLABLA)
    58116  SET( CHATCLIENT_SRC_FILES
  • code/branches/merge/src/network/ConnectionManager.cc

    r1264 r1278  
    4040#include <iostream>
    4141// boost.thread library for multithreading support
    42 #include <boost/thread/thread.hpp>
    4342#include <boost/bind.hpp>
    4443
     
    6362namespace network
    6463{
    65   boost::thread_group network_threads;
    66  
    67   ConnectionManager::ConnectionManager(){}
    68  
    69   ConnectionManager::ConnectionManager(ClientInformation *head) {
     64  //boost::thread_group network_threads;
     65 
     66  ConnectionManager::ConnectionManager():receiverThread_(0){}
     67 
     68  ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) {
    7069    quit=false;
    7170    bindAddress.host = ENET_HOST_ANY;
     
    7473  }
    7574
    76   ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head) {
     75  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head) :receiverThread_(0) {
    7776    quit=false;
    7877    enet_address_set_host (& bindAddress, address.c_str());
     
    8180  }
    8281
    83   ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head) {
     82  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head) : receiverThread_(0) {
    8483    quit=false;
    8584    enet_address_set_host (& bindAddress, address);
     
    111110
    112111  void ConnectionManager::createListener() {
    113     network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
    114     //     boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
     112    receiverThread_ = new boost::thread(boost::bind(&ConnectionManager::receiverThread, this));
     113    //network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
     114         //boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
    115115    return;
    116116  }
     
    118118  bool ConnectionManager::quitListener() {
    119119    quit=true;
    120     network_threads.join_all();
     120    //network_threads.join_all();
     121    receiverThread_->join();
    121122    return true;
    122123  }
     
    202203      }
    203204//       usleep(100);
    204       //yield(); //TODO: find apropriate
     205      receiverThread_->yield(); //TODO: find apropriate
    205206    }
    206207    disconnectClients();
  • code/branches/merge/src/network/ConnectionManager.h

    r1264 r1278  
    4747// enet library for networking support
    4848#include <enet/enet.h>
     49#include <boost/thread/thread.hpp>
    4950
    5051#include "PacketBuffer.h"
     
    112113    ClientInformation *head_;
    113114
    114    
     115    boost::thread *receiverThread_;
    115116//     int getNumberOfClients();
    116117    //functions to map what object every clients uses
Note: See TracChangeset for help on using the changeset viewer.