Changeset 3302
- Timestamp:
- Jul 18, 2009, 5:13:38 PM (15 years ago)
- Location:
- code/branches/netp6/src/network
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp6/src/network/ClientInformation.h
r3198 r3302 87 87 static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false); 88 88 static ClientInformation *getBegin(){return head_;} 89 static bool hasClients(){ return ClientInformation::head_!=0; } 89 90 90 91 bool setSynched(bool s); -
code/branches/netp6/src/network/Connection.cc
r3214 r3302 31 31 #include <cassert> 32 32 #include <enet/enet.h> 33 #include <OgreTimer.h>34 33 #include "packet/Packet.h" 35 34 … … 77 76 78 77 assert(this->host_); 79 Ogre::Timer timer;80 78 81 while( timer.getMilliseconds()<NETWORK_MAX_QUEUE_PROCESS_TIME &&enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )79 while( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 ) 82 80 { 83 81 switch(event.type){ -
code/branches/netp6/src/network/GamestateManager.cc
r3240 r3302 99 99 100 100 bool GamestateManager::processGamestates(){ 101 if( this->gamestateQueue.empty() ) 102 return true; 101 103 std::map<unsigned int, packet::Gamestate*>::iterator it; 102 104 // now push only the most recent gamestates we received (ignore obsolete ones) … … 141 143 int cid = temp->getID(); //get client id 142 144 143 packet::Gamestate *gs;144 145 unsigned int gID = temp->getGamestateID(); 145 146 if(!reference) … … 242 243 243 244 assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID); 244 COUT( 4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;245 COUT(5) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl; 245 246 std::map<unsigned int, packet::Gamestate*>::iterator it; 246 247 for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; ){ -
code/branches/netp6/src/network/Server.cc
r3240 r3302 49 49 #include "core/ObjectList.h" 50 50 #include "core/Executor.h" 51 #include "core/ThreadPool.h"52 51 #include "packet/Chat.h" 53 52 #include "packet/ClassID.h" … … 71 70 Server::Server() { 72 71 this->timeSinceLastUpdate_=0; 73 this->threadPool_ = new ThreadPool();74 72 } 75 73 … … 77 75 this->setPort( port ); 78 76 this->timeSinceLastUpdate_=0; 79 this->threadPool_ = new ThreadPool();80 77 } 81 78 … … 89 86 this->setBindAddress( bindAddress ); 90 87 this->timeSinceLastUpdate_=0; 91 this->threadPool_ = new ThreadPool();92 88 } 93 89 … … 96 92 */ 97 93 Server::~Server(){ 98 delete this->threadPool_;99 94 } 100 95 … … 141 136 // receive incoming packets 142 137 Connection::processQueue(); 143 // process incoming gamestates144 GamestateManager::processGamestates();145 138 146 // pass sendFunctionCalls to worker thread pool 147 ExecutorStatic* functioncalls = createExecutor( createFunctor(&FunctionCallManager::sendCalls) ); 148 this->threadPool_->passFunction( functioncalls, true ); 149 150 this->threadPool_->synchronise(); 151 152 //this steers our network frequency 153 timeSinceLastUpdate_+=time.getDeltaTime(); 154 if(timeSinceLastUpdate_>=NETWORK_PERIOD) 139 if ( ClientInformation::hasClients() ) 155 140 { 156 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 157 // ExecutorMember<GamestateManager>* updategamestate = createExecutor( createFunctor(&GamestateManager::updateGamestate); 158 // updategamestate->setObject( static_cast<GamestateManager*>(this) ); 159 // this->threadPool_->passFunction( updategamestate ); 160 updateGamestate(); 161 } 162 sendPackets(); // flush the enet queue 141 // process incoming gamestates 142 GamestateManager::processGamestates(); 143 144 // send function calls to clients 145 FunctionCallManager::sendCalls(); 146 147 //this steers our network frequency 148 timeSinceLastUpdate_+=time.getDeltaTime(); 149 if(timeSinceLastUpdate_>=NETWORK_PERIOD) 150 { 151 timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD; 152 updateGamestate(); 153 } 154 sendPackets(); // flush the enet queue 155 } 163 156 } 164 157 -
code/branches/netp6/src/network/Server.h
r3240 r3302 76 76 void syncClassid(unsigned int clientID); 77 77 78 ThreadPool* threadPool_;79 78 float timeSinceLastUpdate_; 80 79 }; -
code/branches/netp6/src/network/packet/ClassID.cc
r3214 r3302 142 142 classname = temp+2*sizeof(uint32_t); 143 143 id=ClassByString( std::string((const char*)classname) ); 144 COUT( 0) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;144 COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl; 145 145 if(id==NULL){ 146 146 COUT(0) << "Recieved a bad classname" << endl; -
code/branches/netp6/src/network/packet/FunctionIDs.cc
r3214 r3302 132 132 stringsize = *(uint32_t*)(temp+sizeof(uint32_t)); 133 133 functionname = temp+2*sizeof(uint32_t); 134 COUT( 0) << "processing functionid: " << networkID << " name: " << functionname << std::endl;134 COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl; 135 135 NetworkFunctionBase::setNetworkID((const char*)functionname, networkID); 136 136 temp += 2*sizeof(uint32_t) + stringsize; -
code/branches/netp6/src/network/synchronisable/Synchronisable.cc
r3240 r3302 96 96 if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer())) 97 97 deletedObjects_.push(objectID); 98 // delete all Synchronisable Variables from syncList ( which are also in stringList )99 for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)100 delete (*it);101 syncList.clear();102 stringList.clear();103 }98 } 99 // delete all Synchronisable Variables from syncList ( which are also in stringList ) 100 for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++) 101 delete (*it); 102 syncList.clear(); 103 stringList.clear(); 104 104 std::map<uint32_t, Synchronisable*>::iterator it; 105 105 it = objectMap_.find(objectID); -
code/branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc
r3227 r3302 38 38 namespace orxonox{ 39 39 40 // template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)41 // {42 // if (bidirectional)43 // syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));44 // else45 // syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));46 // stringList.push_back(syncList.back());47 // }48 49 40 template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 50 41 { 42 SynchronisableVariableBase* sv; 51 43 if (bidirectional) 52 s yncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));44 sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb); 53 45 else 54 syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb)); 55 stringList.push_back(syncList.back()); 46 sv = new SynchronisableVariable<const std::string>(variable, mode, cb); 47 syncList.push_back(sv); 48 stringList.push_back(sv); 56 49 } 57 50
Note: See TracChangeset
for help on using the changeset viewer.