Changeset 2944
- Timestamp:
- May 1, 2009, 9:47:34 AM (16 years ago)
- Location:
- code/branches/netp2/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp2/src/network/FunctionCallManager.cc
r2937 r2944 57 57 { 58 58 std::map<uint32_t, packet::FunctionCalls*>::iterator it; 59 for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); it++) 59 for (it = FunctionCallManager::clientMap_.begin(); it != FunctionCallManager::clientMap_.end(); ) 60 { 60 61 it->second->send(); 62 clientMap_.erase(it++); 63 } 61 64 } 62 65 -
code/branches/netp2/src/network/NetworkFunction.cc
r2937 r2944 58 58 59 59 60 NetworkFunctionStatic::NetworkFunctionStatic(Functor * functor, std::string name, const NetworkFunctionPointer& p):60 NetworkFunctionStatic::NetworkFunctionStatic(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p): 61 61 NetworkFunctionBase(name) 62 62 { 63 63 RegisterObject(NetworkFunctionStatic); 64 64 65 this->functor_ = functor; 65 66 functorMap_[p] = this; 66 67 idMap_[ this->getNetworkID() ] = this; -
code/branches/netp2/src/network/NetworkFunction.h
r2943 r2944 77 77 static inline bool isStatic( uint32_t networkID ) { return isStaticMap_[networkID]; } 78 78 79 80 79 static inline void setNetworkID(std::string name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); } 81 80 81 protected: 82 static std::map<uint32_t, bool> isStaticMap_; 83 82 84 private: 83 85 static std::map<std::string, NetworkFunctionBase*> nameMap_; 84 static std::map<uint32_t, bool> isStaticMap_;85 86 uint32_t networkID_; 86 87 std::string name_; … … 91 92 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase { 92 93 public: 93 NetworkFunctionStatic(Functor * functor, std::string name, const NetworkFunctionPointer& p);94 NetworkFunctionStatic(FunctorStatic* functor, std::string name, const NetworkFunctionPointer& p); 94 95 ~NetworkFunctionStatic(); 95 96 … … 152 153 FunctorMember<T>* functor_; 153 154 }; 155 156 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(FunctorMember<T>* functor, std::string name, const NetworkFunctionPointer& p): 157 NetworkMemberFunctionBase(name, p), functor_(functor) 158 { 159 } 154 160 155 161 -
code/branches/netp2/src/network/Server.cc
r2773 r2944 60 60 #include "util/Convert.h" 61 61 #include "ChatListener.h" 62 #include "FunctionCallManager.h" 63 #include "packet/FunctionIDs.h" 64 62 65 63 66 namespace orxonox … … 157 160 gamestates_->processGamestates(); 158 161 updateGamestate(); 162 FunctionCallManager::sendCalls(); 159 163 } 160 164 } … … 340 344 return false; 341 345 } 342 COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl; 346 COUT(5) << "Con.Man: creating client id: " << temp->getID() << std::endl; 347 348 // synchronise class ids 343 349 connection->syncClassid(temp->getID()); 350 351 // now synchronise functionIDs 352 packet::FunctionIDs *fIDs = new packet::FunctionIDs(); 353 bool b = fIDs->send(); 354 assert(b); 355 344 356 temp->setSynched(true); 345 COUT( 3) << "sending welcome" << std::endl;357 COUT(4) << "sending welcome" << std::endl; 346 358 packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID()); 347 359 w->setClientID(temp->getID()); 348 b ool b= w->send();360 b = w->send(); 349 361 assert(b); 350 362 packet::Gamestate *g = new packet::Gamestate(); -
code/branches/netp2/src/network/packet/FunctionCalls.cc
r2938 r2944 72 72 { 73 73 uint32_t functionID = *(uint32_t*)temp; 74 bool isStatic = NetworkFunctionBase::isStatic( functionID);74 bool isStatic = *(uint8_t*)(temp+sizeof(uint32_t)); 75 75 if( isStatic ) 76 76 { 77 77 MultiType mt1, mt2, mt3, mt4, mt5; 78 78 NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( functionID ); 79 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t) );80 temp+=2*sizeof(uint32_t) ;79 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)); 80 temp+=2*sizeof(uint32_t)+sizeof(uint8_t); 81 81 switch(nrOfArguments) 82 82 { … … 122 122 MultiType mt1, mt2, mt3, mt4, mt5; 123 123 NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( functionID ); 124 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t) );125 uint32_t objectID = *(uint32_t*)(temp+2*sizeof(uint32_t) );126 temp+=3*sizeof(uint32_t) ;124 uint32_t nrOfArguments = *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)); 125 uint32_t objectID = *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t)); 126 temp+=3*sizeof(uint32_t)+sizeof(uint8_t); 127 127 switch(nrOfArguments) 128 128 { … … 166 166 } 167 167 } 168 delete this; 168 169 return true; 169 170 } … … 173 174 174 175 // first determine the size that has to be reserved for this call 175 uint32_t callsize = 2*sizeof(uint32_t) ; //size for network-function-id and nrOfArguments176 uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic 176 177 uint32_t nrOfArguments = 0; 177 178 if(mt1) … … 211 212 } 212 213 213 // now serialise the mt values and copy the function id 214 // now serialise the mt values and copy the function id and isStatic 214 215 uint8_t* temp = data_+currentSize_; 215 216 *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls 216 217 *(uint32_t*)temp = networkID; 217 *(uint32_t*)(temp+sizeof(uint32_t)) = nrOfArguments; 218 temp += 2*sizeof(uint32_t); 218 *(uint8_t*)(temp+sizeof(uint32_t)) = true; 219 *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments; 220 temp += 2*sizeof(uint32_t)+sizeof(uint8_t); 219 221 if(mt1) 220 222 { … … 237 239 } 238 240 } 239 currentSize_ += callsize; 241 //currentSize_ += callsize; 242 currentSize_ = temp-data_; 240 243 241 244 } … … 245 248 246 249 // first determine the size that has to be reserved for this call 247 uint32_t callsize = 3*sizeof(uint32_t) ; //size for network-function-id and nrOfArguments and the objectID250 uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID 248 251 uint32_t nrOfArguments = 0; 249 252 if(mt1) … … 287 290 *(uint32_t*)(data_+sizeof(uint32_t)) = *(uint32_t*)(data_+sizeof(uint32_t))+1; // increase number of calls 288 291 *(uint32_t*)temp = networkID; 289 *(uint32_t*)(temp+sizeof(uint32_t)) = nrOfArguments; 290 *(uint32_t*)(temp+2*sizeof(uint32_t)) = objectID; 291 temp += 3*sizeof(uint32_t); 292 *(uint8_t*)(temp+sizeof(uint32_t)) = false; 293 *(uint32_t*)(temp+sizeof(uint32_t)+sizeof(uint8_t)) = nrOfArguments; 294 *(uint32_t*)(temp+2*sizeof(uint32_t)+sizeof(uint8_t)) = objectID; 295 temp += 3*sizeof(uint32_t)+sizeof(uint8_t); 292 296 if(mt1) 293 297 { -
code/branches/netp2/src/network/packet/Packet.cc
r2937 r2944 39 39 40 40 #include "Acknowledgement.h" 41 #include "DeleteObjects.h" 41 42 #include "Chat.h" 42 43 #include "ClassID.h" 44 #include "FunctionCalls.h" 45 #include "FunctionIDs.h" 43 46 #include "Gamestate.h" 44 47 #include "Welcome.h" 45 #include "DeleteObjects.h"46 48 #include "network/Host.h" 47 49 #include "core/CoreIncludes.h" … … 172 174 unsigned int clientID = ClientInformation::findClient(&peer->address)->getID(); 173 175 Packet *p = 0; 174 COUT( 5) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;176 COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl; 175 177 switch( *(ENUM::Type *)(data + _PACKETID) ) 176 178 { 177 179 case ENUM::Acknowledgement: 178 COUT( 4) << "ack" << std::endl;180 COUT(5) << "ack" << std::endl; 179 181 p = new Acknowledgement( data, clientID ); 180 182 break; 181 183 case ENUM::Chat: 182 COUT( 4) << "chat" << std::endl;184 COUT(5) << "chat" << std::endl; 183 185 p = new Chat( data, clientID ); 184 186 break; 185 187 case ENUM::ClassID: 186 COUT( 4) << "classid" << std::endl;188 COUT(5) << "classid" << std::endl; 187 189 p = new ClassID( data, clientID ); 188 190 break; 189 191 case ENUM::Gamestate: 190 COUT( 4) << "gamestate" << std::endl;192 COUT(5) << "gamestate" << std::endl; 191 193 // TODO: remove brackets 192 194 p = new Gamestate( data, clientID ); 193 195 break; 194 196 case ENUM::Welcome: 195 COUT( 4) << "welcome" << std::endl;197 COUT(5) << "welcome" << std::endl; 196 198 p = new Welcome( data, clientID ); 197 199 break; 198 200 case ENUM::DeleteObjects: 199 COUT( 4) << "deleteobjects" << std::endl;201 COUT(5) << "deleteobjects" << std::endl; 200 202 p = new DeleteObjects( data, clientID ); 203 break; 204 case ENUM::FunctionCalls: 205 COUT(5) << "functionCalls" << std::endl; 206 p = new FunctionCalls( data, clientID ); 207 break; 208 case ENUM::FunctionIDs: 209 COUT(5) << "functionIDs" << std::endl; 210 p = new FunctionIDs( data, clientID ); 201 211 break; 202 212 default: -
code/branches/netp2/src/network/synchronisable/SynchronisableVariable.h
r2861 r2944 268 268 else{ 269 269 // apply data 270 mem += sizeof(varReference_); 271 if ( checkEquality( this->variable_, mem )==true ) 270 if ( checkEquality( this->variable_, mem+sizeof(varReference_) )==true ) 272 271 { 273 272 mem += getSize( mode ); … … 276 275 else 277 276 { 277 mem += sizeof(varReference_); 278 278 memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(T)); 279 279 if ( this->callback_ != 0 ) -
code/branches/netp2/src/orxonox/objects/Test.cc
r2937 r2944 82 82 83 83 84 85 86 84 void Test::registerVariables() 85 { 86 registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 )); 87 87 registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 )); 88 88 registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true ); 89 89 registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true ); 90 90 … … 93 93 registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true ); 94 94 registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true ); 95 95 } 96 96 97 97 void Test::call(unsigned int clientID) 98 98 { 99 callStaticNetworkFunction( &Test::printV1, clientID ); 99 100 callStaticNetworkFunction( &Test::printV1, clientID ); 100 101 } -
code/branches/netp2/src/orxonox/objects/Test.h
r2937 r2944 50 50 void registerVariables(); 51 51 52 void call(unsigned int clientID);52 static void call(unsigned int clientID); 53 53 54 54
Note: See TracChangeset
for help on using the changeset viewer.