Changeset 2758
- Timestamp:
- Mar 8, 2009, 4:40:01 PM (16 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/ConnectionManager.cc
r2749 r2758 46 46 #include <boost/bind.hpp> 47 47 48 // #include "core/CoreIncludes.h"49 // #include "core/BaseObject.h"50 // #include "core/Iterator.h"51 48 #include "util/Math.h" 52 49 #include "util/Sleep.h" … … 124 121 void ConnectionManager::createListener() { 125 122 receiverThread_ = new boost::thread(boost::bind(&ConnectionManager::receiverThread, this)); 126 //network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));127 //boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));128 123 return; 129 124 } … … 131 126 bool ConnectionManager::quitListener() { 132 127 quit=true; 133 //network_threads.join_all();134 128 receiverThread_->join(); 135 129 return true; … … 206 200 // log handling ================ 207 201 case ENET_EVENT_TYPE_CONNECT: 208 //COUT(3) << "adding event_type_connect to queue" << std::endl;209 202 case ENET_EVENT_TYPE_DISCONNECT: 210 //addClient(event);211 //this is a workaround to ensure thread safety212 //COUT(5) << "Con.Man: connection event has occured" << std::endl;213 //break;214 203 case ENET_EVENT_TYPE_RECEIVE: 215 //std::cout << "received data" << std::endl;216 //COUT(5) << "Con.Man: receive event has occured" << std::endl;217 // only add, if client has connected yet and not been disconnected218 //if(head_->findClient(&event->peer->address))219 204 processData(event); 220 205 event = new ENetEvent; 221 // else222 // COUT(3) << "received a packet from a client we don't know" << std::endl;223 206 break; 224 //case ENET_EVENT_TYPE_DISCONNECT:225 //clientDisconnect(event->peer);226 //break;227 207 case ENET_EVENT_TYPE_NONE: 228 208 //receiverThread_->yield(); … … 299 279 } 300 280 301 /**302 *303 * @param clientID304 */305 // void ConnectionManager::syncClassid(unsigned int clientID) {306 // unsigned int network_id=0, failures=0;307 // std::string classname;308 // Identifier *id;309 // std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();310 // while(it != Factory::getFactoryMapEnd()){311 // id = (*it).second;312 // if(id == NULL)313 // continue;314 // classname = id->getName();315 // network_id = id->getNetworkID();316 // if(network_id==0)317 // COUT(3) << "we got a null class id: " << id->getName() << std::endl;318 // COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;319 //320 // packet::ClassID *classid = new packet::ClassID( network_id, classname );321 // classid->setClientID(clientID);322 // while(!classid->send() && failures < 10){323 // failures++;324 // }325 // ++it;326 // }327 // //sendPackets();328 // COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;329 // }330 281 331 282 void ConnectionManager::syncClassid(unsigned int clientID) { -
code/branches/network/src/network/ConnectionManager.h
r2171 r2758 76 76 static boost::recursive_mutex enet_mutex; 77 77 ConnectionManager(); 78 //ConnectionManager(ClientInformation *head);79 78 ConnectionManager(int port); 80 79 ConnectionManager(int port, const char *address); 81 80 ConnectionManager(int port, const std::string& address); 82 81 ~ConnectionManager(); 83 //ENetPacket *getPacket(ENetAddress &address); // thread184 //ENetPacket *getPacket(int &clientID);85 82 ENetEvent *getEvent(); 86 83 bool queueEmpty(); 87 84 void createListener(); 88 85 bool quitListener(); 89 // bool addPacket(Packet::Packet *packet);90 86 static bool addPacket(ENetPacket *packet, ENetPeer *peer); 91 87 static bool addPacket(ENetPacket *packet, int ID); 92 88 static bool addPacketAll(ENetPacket *packet); 93 // bool sendPackets(ENetEvent *event);94 89 bool sendPackets(); 95 //bool createClient(int clientID);96 90 void disconnectClient(ClientInformation *client); 97 91 void syncClassid(unsigned int clientID); 98 92 99 93 private: 100 // bool clientDisconnect(ENetPeer *peer);101 // bool removeClient(int clientID);102 94 bool processData(ENetEvent *event); 103 //bool addClient(ENetEvent *event);104 95 void receiverThread(); 105 96 void disconnectClients(); -
code/branches/network/src/network/packet/ClassID.cc
r2749 r2758 155 155 156 156 157 // uint32_t ClassID::getClassID(){158 // return *(uint32_t *)(data_ + _CLASSID);159 // }160 161 157 } //namespace packet 162 158 }//namespace orxonox -
code/branches/network/src/network/packet/ClassID.h
r2749 r2758 52 52 bool process(); 53 53 54 // uint32_t getClassID();55 // uint32_t getClassNameLength(){ return classNameLength_; }56 // const char *getClassName(){ return (const char*)(data_+_CLASSNAME); }57 54 private: 58 // uint32_t classNameLength_;59 // static bool alreadySetOneClassID_;60 55 }; 61 56 -
code/branches/network/src/network/packet/Gamestate.cc
r2710 r2758 48 48 #define PACKET_FLAG_GAMESTATE ENET_PACKET_FLAG_RELIABLE 49 49 50 // Gamestate::Gamestate()51 // {52 // flags_ = flags_ | PACKET_FLAG_GAMESTATE;53 // }54 50 55 51 Gamestate::Gamestate() … … 127 123 #endif 128 124 129 //if(it->doSelection(id))130 125 if ( it->doSync( id, mode ) ) 131 126 dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) ); 132 // dataMap_[mem-data_]=(*it); // save the mem location of the synchronisable data133 127 if(!it->getData(mem, id, mode)) 134 128 return false; // mem pointer gets automatically increased because of call by reference … … 158 152 assert(!header_->isDiffed()); 159 153 uint8_t *mem=data_+GamestateHeader::getSize(); 160 // get the start of the Synchronisable list161 //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin();162 154 Synchronisable *s; 163 155 … … 177 169 mem += objectheader.getDataSize(); 178 170 } 179 // COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;180 // else181 // COUT(0) << "fabricated: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;182 171 } 183 172 else 184 173 { 185 174 bool b = s->updateData(mem, mode); 186 // if(!b)187 // COUT(0) << "data could not be updated" << endl;188 175 assert(b); 189 176 } … … 262 249 uint8_t *ndata = new uint8_t[buffer+GamestateHeader::getSize()]; 263 250 uint8_t *dest = ndata + GamestateHeader::getSize(); 264 //unsigned char *dest = new unsigned char[buffer];265 251 uint8_t *source = data_ + GamestateHeader::getSize(); 266 252 int retval; … … 294 280 uint32_t compsize = header_->getCompSize(); 295 281 uint32_t bufsize; 296 // assert(compsize<=datasize);297 282 bufsize = datasize; 298 283 assert(bufsize!=0); … … 340 325 assert(!header_->isDiffed()); 341 326 GamestateHeader diffHeader(base->data_); 342 //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;343 327 uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_); 344 328 uint32_t of=0; // pointers offset … … 397 381 //copy in the zeros 398 382 for(it=dataMap_.begin(); it!=dataMap_.end();){ 399 // if((*it).objSize==0)400 // continue;401 // if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this402 // continue; // merged from objecthierarchy2, doesn't work anymore; TODO: change this403 383 SynchronisableHeader oldobjectheader(origdata); 404 384 SynchronisableHeader newobjectheader(newdata); … … 408 388 continue; 409 389 } 410 // object = Synchronisable::getSynchronisable( (*it).objID );411 // assert(object->objectID == oldobjectheader->objectID);412 390 objectsize = oldobjectheader.getDataSize(); 413 391 objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader … … 447 425 assert(header_->isDiffed()); 448 426 assert(!header_->isCompressed() && !base->header_->isCompressed()); 449 //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;450 427 uint8_t *basep = GAMESTATE_START(base->data_); 451 428 uint8_t *gs = GAMESTATE_START(this->data_); -
code/branches/network/src/network/packet/Gamestate.h
r2662 r2758 93 93 private: 94 94 uint8_t *data_; 95 //#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))96 //#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)97 //#define HEADER GAMESTATE_HEADER(data_)98 95 99 96 }; -
code/branches/network/src/network/synchronisable/Synchronisable.cc
r2749 r2758 100 100 if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer())) 101 101 deletedObjects_.push(objectID); 102 // COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;103 // COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;104 // assert(objectMap_[objectID]->objectID==objectID);105 // objectMap_.erase(objectID);106 102 } 107 103 std::map<uint32_t, Synchronisable*>::iterator it; … … 110 106 objectMap_.erase(it); 111 107 112 //HACK HACK HACK HACK HACK HACK113 // this hack ensures that children of this object also get destroyed114 // ObjectList<Synchronisable>::iterator it2, it3;115 // // get total size of gamestate116 // for(it2 = ObjectList<Synchronisable>::begin(); it2; ++it2)117 // {118 // if ( it2->getCreatorID() == this->objectID && it2->getCreatorID() != OBJECTID_UNKNOWN )119 // {120 // Synchronisable::deleteObject( it2->getObjectID() );121 // }122 // }123 //HACK HACK HACK HACK HACK HACK124 108 } 125 109 … … 205 189 */ 206 190 bool Synchronisable::deleteObject(uint32_t objectID){ 207 // assert(getSynchronisable(objectID));208 191 if(!getSynchronisable(objectID)) 209 192 return false; 210 193 assert(getSynchronisable(objectID)->objectID==objectID); 211 // delete objectMap_[objectID];212 194 Synchronisable *s = getSynchronisable(objectID); 213 195 if(s) … … 260 242 if(!doSync(id, mode)) 261 243 return true; 262 //std::cout << "inside getData" << std::endl;263 244 uint32_t tempsize = 0; 264 245 if (this->classID==0) … … 269 250 270 251 assert(this->classID==this->getIdentifier()->getNetworkID()); 271 // this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this272 252 std::list<SynchronisableVariableBase*>::iterator i; 273 253 uint32_t size; … … 307 287 mode=state_; 308 288 std::list<SynchronisableVariableBase *>::iterator i; 309 //assert(objectMode_!=0x0);310 //assert( (mode ^ objectMode_) != 0);311 289 if(syncList.empty()){ 312 290 assert(0); -
code/branches/network/src/network/synchronisable/Synchronisable.h
r2710 r2758 142 142 protected: 143 143 Synchronisable(BaseObject* creator); 144 // void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);145 144 template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false); 146 145 template <class T> void unregisterVariable(T& var); … … 205 204 template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 206 205 template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); 207 // template <> _NetworkExport void Synchronisable::registerVariable( LODParticle::LOD& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);208 // template <> _NetworkExport void Synchronisable::registerVariable( Ogre::Light::LightTypes& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);209 206 } 210 207
Note: See TracChangeset
for help on using the changeset viewer.