#include <LobbyServer.h>
Class for SimpleModule LobbyServer.ned . Should be part of Compound Module CentralLobbyServer.ned This class handels all messages. It holds a Pointer to one PlayerTable and one SubSpaceTable. It calls BootstrapOracle->registerPeer on initialize(). LobbyServer should be the only entry in the BootstrapOracle. It also collects statistics about usage on finish().
Public Member Functions | |
~LobbyServer () | |
virtual int | numInitStages () const |
void | initialize () |
initializes base-class-attributes | |
void | finish () |
Private Member Functions | |
void | informNeighbors (SubSpace *subSpace) |
bool | createResponsibleNode (int id) |
int | login (int id, IPAddress ip, int Bandwith, int Cpu) |
bool | logout (int id) |
void | addSubSpaceToOpenLogins (int subSpaceId) |
void | sendWaitingRequests (int subSpaceId, int nodeType) |
void | sendPing (PingMessage *openPing) |
void | processPingTimer () |
void | processStabilizeTimer () |
void | processSelfTimers (cMessage *msg) |
void | processLogin (LoginMessage *loginMsg) |
Message Handling. | |
void | processLogout (LogoutMessage *logoutMsg) |
void | processCreate (CreateNodeMessage *createMsg) |
void | processRequestIp (RequestIpMessage *requestMsg) |
void | processRequestNode (RequestNodeMessage *requestMsg) |
void | processUpdateRespIp (UpdateRespIpMessage *updateMsg) |
void | processReplacement (ReplacementMessage *replaceMsg) |
void | processPing (PingMessage *pingMsg) |
void | processStabilize (StabilizeMessage *smsg) |
Private Attributes | |
PlayerTable * | playerOnlineTable |
SubSpaceTable * | subSpaceTable |
int | gameSpaceSize |
int | subSpaceSize |
int | maxFailedPings |
int | completedLogins |
bool | thereIsANotReadyCreate |
LobbyServer::~LobbyServer | ( | ) |
virtual int LobbyServer::numInitStages | ( | void | ) | const [inline, virtual] |
void LobbyServer::initialize | ( | ) | [virtual] |
initializes base-class-attributes
At Stage 5 it reads parameters from .ini , creates playerOnlineTable and subSpaceTable setup Watches etc and calls BootstrapOracle->registerPeer
Reimplemented from YMMOGBase.
00039 { 00040 // Get Parameters 00041 gameSpaceSize = par("gameSpaceSize"); 00042 subSpaceSize = par("subSpaceSize"); 00043 // Initialisierung 00044 playerOnlineTable = check_and_cast<PlayerTable*>(parentModule()->submodule("playerOnlineTable")); 00045 subSpaceTable = check_and_cast<SubSpaceTable*>(simulation.moduleByPath("globalObserver.globalFunctions[0]")); 00046 // find a new bootstrap node and enroll to the bootstrap list 00047 bootstrapOracle->registerPeer(thisNode); 00048 00049 subSpaceTable->createTable(gameSpaceSize); 00050 00051 resendDelay = 1.5; 00052 00053 // Initiate Timer 00054 pingTimer = new cMessage("pingTimer"); 00055 pingDelay = 30; 00056 scheduleAt(simTime() + pingDelay, pingTimer); 00057 00058 maxFailed = 3; 00059 00060 maxFailedPings = 2; 00061 droppedMessages = 0; 00062 WATCH( droppedMessages ); 00063 00064 thereIsANotReadyCreate = false; 00065 // Statistics 00066 WATCH(completedLogins); 00067 completedLogins=0; 00068 }
void LobbyServer::finish | ( | ) | [virtual] |
Reimplemented from YMMOGBase.
00070 { 00071 // delete from bootstrap 00072 bootstrapOracle->removePeer(thisNode); 00073 finishStats(); 00074 }
void LobbyServer::informNeighbors | ( | SubSpace * | subSpace | ) | [private] |
00198 { 00199 for( int i=0; i < 8; i++) { 00200 if( subSpace->getNeighbor(i) != (IPAddress) "127.0.0.1" ) { 00201 UpdateRespIpMessage* updateMsg = new UpdateRespIpMessage("Update Responsible Ip"); 00202 updateMsg->setCommand(UPDATERESPIP); 00203 updateMsg->setServiceType(REQUEST); 00204 if( i < 3 ) { updateMsg->setSubSpaceId(subSpace->getId() - gameSpaceSize + i - 1 ); } 00205 else if( i == 3) { updateMsg->setSubSpaceId(subSpace->getId() - 1 ); } 00206 else if( i == 4) { updateMsg->setSubSpaceId(subSpace->getId() + 1 ); } 00207 else if (i >= 5) { updateMsg->setSubSpaceId(subSpace->getId() + gameSpaceSize + i - 6 ); } 00208 updateMsg->setDirection(7-i); 00209 updateMsg->setUpdatedIp(subSpace->getRespIp()); 00210 sendMsg(updateMsg, subSpace->getNeighbor(i)); 00211 } 00212 } 00213 }
bool LobbyServer::createResponsibleNode | ( | int | id | ) | [private] |
00154 { 00155 std::list<YMMOGMessage*>::iterator w = notReadyMessages.begin(); 00156 //check if there is a CreateMsg already waiting 00157 while ( w != notReadyMessages.end() ) { 00158 if( (*w)->getCommand() == CREATE ) { 00159 CreateNodeMessage* cmsg = dynamic_cast<CreateNodeMessage*>(*w); 00160 if( cmsg != NULL && cmsg->getSubSpaceToCreate().getId() == subSpaceId && cmsg->getNodeType() == RESPONSIBLENODE ) { 00161 w = notReadyMessages.erase(w); 00162 } 00163 else { ++w; } 00164 } 00165 else { 00166 ++w; 00167 } 00168 } 00169 //check if there is already an create on its way: 00170 w = dupedMessages.begin(); 00171 while( w != dupedMessages.end() ) { 00172 if( (*w)->getCommand() == CREATE) { 00173 CreateNodeMessage* cmsg = dynamic_cast<CreateNodeMessage*>(*w); 00174 if( cmsg != NULL && cmsg->getSubSpaceToCreate().getId() == subSpaceId && cmsg->getNodeType() == RESPONSIBLENODE && cmsg->getJobType() == CREATENODE ) { 00175 return false; 00176 } 00177 } 00178 ++w; 00179 } 00180 //Create a new CreateNodeMessage 00181 IPAddress destip = (playerOnlineTable->getHeadAndModify(subSpaceId, (IPAddress) "127.0.0.1", -110)).getIp(); 00182 CreateNodeMessage* createMsg = new CreateNodeMessage(); 00183 createMsg->setCommand(CREATE); 00184 createMsg->setServiceType(REQUEST); 00185 createMsg->setNodeType(RESPONSIBLENODE); 00186 createMsg->setJobType(CREATENODE); 00187 createMsg->setSubSpaceToCreate( *(subSpaceTable->getSubSpace(subSpaceId)) ); 00188 if( destip != (IPAddress) "127.0.0.1") { 00189 sendMsg(createMsg, destip); 00190 return true; 00191 } 00192 else { 00193 notReadyMessages.push_back( createMsg ); 00194 return false; 00195 } 00196 }
int LobbyServer::login | ( | int | id, | |
IPAddress | ip, | |||
int | Bandwith, | |||
int | Cpu | |||
) | [private] |
bool LobbyServer::logout | ( | int | id | ) | [private] |
void LobbyServer::addSubSpaceToOpenLogins | ( | int | subSpaceId | ) | [private] |
00216 { 00217 std::list<YMMOGMessage*>::iterator i = notReadyMessages.begin(); 00218 while( i != notReadyMessages.end() ) { 00219 if( (*i)->getCommand() == LOGIN) { 00220 LoginMessage* loginMsg = dynamic_cast<LoginMessage*>(*i); 00221 if( loginMsg != NULL) { 00222 bool notComplete = false; 00223 for(uint k = 0; k != loginMsg->getResponsibleNodesArraySize(); ++k) { 00224 if( loginMsg->getResponsibleNodes(k).getId() == subSpaceId ) { 00225 loginMsg->setResponsibleNodes(k, (*subSpaceTable->getSubSpace( subSpaceId)) ); 00226 } 00227 if( loginMsg->getResponsibleNodes(k).getRespIp() == (IPAddress) "127.0.0.1" ) 00228 notComplete = true; 00229 } 00230 if ( !notComplete ) { 00231 sendMsg( loginMsg, loginMsg->getSrcip() ); 00232 i = notReadyMessages.erase(i); 00233 } 00234 else { 00235 ++i; 00236 } 00237 } 00238 else { 00239 ++i; 00240 } 00241 } else { ++i; } 00242 } 00243 }
void LobbyServer::sendWaitingRequests | ( | int | subSpaceId, | |
int | nodeType | |||
) | [private] |
00248 { 00249 std::list<YMMOGMessage*>::iterator i = notReadyMessages.begin(); 00250 while( i != notReadyMessages.end() ) { 00251 if( (*i)->getCommand() == REQUESTIP) { 00252 RequestIpMessage* requestMsg = dynamic_cast<RequestIpMessage*>(*i); 00253 if( requestMsg != NULL && requestMsg->getSubSpaceId() == subSpaceId && requestMsg->getNodeType() == nodeType) { 00254 if( nodeType == RESPONSIBLENODE ) { 00255 requestMsg->setRequestedIp( subSpaceTable->getSubSpace( subSpaceId )->getRespIp() ); 00256 } 00257 else if ( nodeType == BACKUPNODE ) { 00258 requestMsg->setRequestedIp( subSpaceTable->getSubSpace( subSpaceId )->getBackupIp() ); 00259 } 00260 sendMsg(requestMsg, requestMsg->getSrcip() ); 00261 i = notReadyMessages.erase(i); 00262 } else { 00263 ++i; 00264 } 00265 } 00266 else { ++i; } 00267 } 00268 }
void LobbyServer::sendPing | ( | PingMessage * | openPing | ) | [private, virtual] |
void LobbyServer::processPingTimer | ( | ) | [private] |
00091 { 00092 selfMessages++; 00093 cancelEvent(pingTimer); 00094 std::list<PingMessage*>::iterator p= pings.begin(); 00095 double next=simTime(); 00096 while( p != pings.end() ) { 00097 if( ( (*p)->getTimeStamp() + pingDelay) < simTime() ) { 00098 (*p)->setTimeStamp(simTime()); 00099 (*p)->setFailed( (*p)->getFailed() + 1 ); 00100 if( (*p)->getFailed() > maxFailedPings ) { 00101 playerOnlineTable->remove((*p)->getDestip()); 00102 delete *p; 00103 p = pings.erase(p); 00104 } 00105 else { 00106 if( next > (*p)->getTimeStamp() ) next = (*p)->getTimeStamp(); 00107 sendPing( (*p) ); 00108 ++p; 00109 } 00110 } 00111 else { ++p; } 00112 } 00113 std::list<PlayerNode>::iterator pn; 00114 for(pn=playerOnlineTable->playerTable.begin(); pn != playerOnlineTable->playerTable.end(); ++pn) { 00115 if( !findOpenPing( pn->getIp() ) ) { 00116 PingMessage* pingMsg = new PingMessage("LobbyPing"); 00117 pingMsg->setCommand(PING); 00118 pingMsg->setServiceType(REQUEST); 00119 pingMsg->setDestip( pn->getIp() ); 00120 pingMsg->setSrcip(thisNode.ip.get4() ); 00121 pingMsg->setFailed(0); 00122 pingMsg->setTimeStamp(simTime()); 00123 pings.push_back(pingMsg); 00124 sendPing( pingMsg ); 00125 } 00126 } 00127 scheduleAt(next + pingDelay, pingTimer); 00128 }
void LobbyServer::processStabilizeTimer | ( | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00532 { 00533 cancelEvent(stabilizeTimer); 00534 int i=0; 00535 for(i=0; i < gameSpaceSize*gameSpaceSize; i++) { 00536 StabilizeMessage* stabilizeMsg = new StabilizeMessage("Stabilze"); 00537 stabilizeMsg->setCommand(STABILIZE); 00538 stabilizeMsg->setServiceType(REQUEST); 00539 stabilizeMsg->setSubSpaceId(i); 00540 stabilizeMsg->setNodeType(RESPONSIBLENODE); 00541 stabilizeMsg->setCorrect(true); 00542 stabilizeMsg->setSubSpace( *(subSpaceTable->getSubSpace( i )) ); 00543 if ( subSpaceTable->getSubSpace(i)->getRespIp() != (IPAddress) "127.0.0.1" ) { 00544 sendMsg( stabilizeMsg, subSpaceTable->getSubSpace(i)->getRespIp() ); 00545 } else { delete stabilizeMsg; } 00546 } 00547 scheduleAt(simTime() + stabilizeDelay, stabilizeTimer); 00548 }
void LobbyServer::processSelfTimers | ( | cMessage * | msg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00075 { 00076 if(msg->isName("resendTimer")) { 00077 processResendTimer(); 00078 } 00079 else if ( msg->isName("pingTimer") ) { 00080 processPingTimer() ; 00081 } 00082 else if (msg->isName("bandwithTimer") ) { 00083 processBandwithTimer(); 00084 } 00085 else if ( msg->isName("stabilizeTimer") ) { 00086 processStabilizeTimer(); 00087 } 00088 }
void LobbyServer::processLogin | ( | LoginMessage * | loginMsg | ) | [private, virtual] |
Message Handling.
function is called everytime a login message arrives.
Reimplemented from YMMOGBase.
00270 { 00274 if( loginMsg->getServiceType() == REQUEST ) 00275 { 00276 if( findOpenLogin(loginMsg->getSrcip() ) ) { 00277 // We already got the login. Its not ready or its already on its way. Timers will do the rest 00278 delete loginMsg; 00279 return; 00280 } 00281 // Get our Id and Position and add ourself to playertable 00282 int id = login( loginMsg->getId(), loginMsg->getSrcip(), loginMsg->getBandwith(), loginMsg->getCpu()); 00283 // Check if we have some waiting Creates 00284 std::list<YMMOGMessage*>::iterator w = notReadyMessages.begin(); 00285 while( w != notReadyMessages.end() ) { 00286 if( (*w)->getCommand() == CREATE ) { 00287 CreateNodeMessage* cmsg = dynamic_cast<CreateNodeMessage*>(*w); 00288 if( cmsg != NULL ) { 00289 IPAddress destip = (playerOnlineTable->getHeadAndModify(cmsg->getSubSpaceToCreate().getId(), (IPAddress) "127.0.0.1", -110)).getIp(); 00290 if( destip != (IPAddress) "127.0.0.1" ) { 00291 sendMsg(*w, destip); 00292 w = notReadyMessages.erase(w); 00293 } 00294 else { 00295 break; 00296 } 00297 } 00298 else { ++w; } 00299 } else { 00300 ++w; 00301 } 00302 } 00303 int xpos = intuniform(0,(subSpaceSize*gameSpaceSize)-1); 00304 int ypos = intuniform(0,(subSpaceSize*gameSpaceSize)-1); 00305 int subSpaceId = ((ypos / subSpaceSize) * gameSpaceSize ) + (xpos / subSpaceSize); 00306 // (Create&)Get ResponsibleNode and neighbors 00307 std::vector<SubSpace*> neighbors = subSpaceTable->getAllNeighbors(subSpaceId); 00308 loginMsg->setResponsibleNodesArraySize( neighbors.size() ); 00309 loginMsg->setServiceType(RESPONSE); 00310 loginMsg->setId( id ); 00311 loginMsg->setXpos(xpos); 00312 loginMsg->setYpos(ypos); 00313 loginMsg->setSubSpaceSize( subSpaceSize ); 00314 loginMsg->setGameSpaceSize( gameSpaceSize ); 00315 bool notComplete = false; 00316 for(unsigned int i=0; i < neighbors.size(); i++) { 00317 loginMsg->setResponsibleNodes(i, *neighbors.at(i) ); 00318 if( neighbors.at(i)->getRespIp() == (IPAddress) "127.0.0.1" ) { 00319 createResponsibleNode( neighbors.at(i)->getId() ); 00320 notComplete = true; 00321 } 00322 } 00323 if(notComplete ) { 00324 notReadyMessages.push_back( loginMsg ); 00325 } else { 00326 sendMsg(loginMsg, loginMsg->getSrcip() ); 00327 } 00328 } 00329 else { 00330 //Confirmation 00331 // Delete Login from openLogins 00332 deleteFromDupedMessages( loginMsg); 00333 delete loginMsg; 00334 completedLogins++; 00335 } 00336 }
void LobbyServer::processLogout | ( | LogoutMessage * | logoutMsg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00404 { 00405 if( ymmog->getServiceType() == REQUEST ) { 00406 LogoutMessage* logoutMsg = (LogoutMessage*) (ymmog); 00407 logoutMsg->setServiceType(RESPONSE); //response 00408 logoutMsg->setSuccessfull( logout(logoutMsg->getId()) ); 00409 sendMsg(logoutMsg, logoutMsg->getSrcip() ); 00410 } 00411 else { // Confirmation 00412 delete ymmog; 00413 } 00414 }
void LobbyServer::processCreate | ( | CreateNodeMessage * | createMsg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00338 { 00339 if( createMsg->getServiceType() == RESPONSE) { 00340 int subSpaceId = createMsg->getSubSpaceToCreate().getId(); 00341 if( createMsg->getJobType() == CREATENODE) { 00342 switch ( createMsg->getNodeType() ) { 00343 case RESPONSIBLENODE: { 00344 if ( createMsg->getCreationSuccessfull() ) { 00345 // Set IP in the SubSpaceTable 00346 subSpaceTable->setResponsibleNode( subSpaceId,createMsg->getSrcip()); 00347 // Inform Neighbor SubSpaces from the new IP 00348 informNeighbors( subSpaceTable->getSubSpace( subSpaceId ) ); 00349 // Probably there are waiting some logins for the create 00350 addSubSpaceToOpenLogins( subSpaceId ); 00351 //Perhaps there are waiting some request Ip's to 00352 sendWaitingRequests( subSpaceId, RESPONSIBLENODE ); 00353 00354 deleteFromDupedMessages(createMsg); 00355 00356 //Create Backup Node for created Responsible Node 00357 CreateNodeMessage* backupCreate = new CreateNodeMessage("backupCreateFinishedResponsibleNodeCreate"); 00358 backupCreate->setCommand(CREATE); 00359 backupCreate->setServiceType(REQUEST); 00360 backupCreate->setNodeType(BACKUPNODE); 00361 backupCreate->setJobType(CREATENODE); 00362 backupCreate->setSubSpaceToCreate( *(subSpaceTable->getSubSpace( subSpaceId )) ); 00363 IPAddress destip = (playerOnlineTable->getHeadAndModify(subSpaceId, createMsg->getSrcip(), -110 )).getIp(); 00364 if( destip != (IPAddress) "127.0.0.1" ){ 00365 sendMsg(backupCreate, destip); 00366 } 00367 else { 00368 backupCreate->setSrcip(createMsg->getSrcip()); 00369 thereIsANotReadyCreate = true; 00370 notReadyMessages.push_back(backupCreate); 00371 } 00372 delete createMsg; 00373 } 00374 else { 00375 // we have to create a new one 00376 delete createMsg; 00377 } 00378 break; 00379 } 00380 case BACKUPNODE: { 00381 subSpaceTable->getSubSpace(subSpaceId)->setBackupIp(createMsg->getSrcip()); 00382 deleteFromDupedMessages(createMsg); 00383 delete createMsg; 00384 break; 00385 } 00386 case INTERMEDIATENODE: { 00387 deleteFromDupedMessages(createMsg); 00388 delete createMsg; 00389 break; 00390 } 00391 } 00392 } 00393 else if( createMsg->getJobType() == DELETENODE ) { 00394 playerOnlineTable->modify(subSpaceId, createMsg->getSrcip(), createMsg->getNodeType() ); 00395 deleteFromDupedMessages(createMsg); 00396 delete createMsg; 00397 } 00398 } 00399 else { 00400 delete createMsg; 00401 } 00402 }
void LobbyServer::processRequestIp | ( | RequestIpMessage * | requestMsg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00417 { 00418 00419 if (requestMsg->getServiceType() == REQUEST ) { 00420 switch ( requestMsg->getNodeType() ) { 00421 case RESPONSIBLENODE: { 00422 if( subSpaceTable->getSubSpace( requestMsg->getSubSpaceId()) != NULL) { 00423 IPAddress requestedIp = subSpaceTable->getSubSpace( requestMsg->getSubSpaceId() )->getRespIp(); 00424 requestMsg->setServiceType(RESPONSE); 00425 if ( requestedIp == (IPAddress) "127.0.0.1" ) { 00426 createResponsibleNode( requestMsg->getSubSpaceId() ); 00427 notReadyMessages.push_back(requestMsg); 00428 } 00429 else { 00430 requestMsg->setRequestedIp( requestedIp ); 00431 sendMsg( requestMsg , requestMsg->getSrcip() ); 00432 } 00433 } 00434 break; 00435 } 00436 default: { 00437 delete requestMsg; 00438 } 00439 } 00440 } 00441 else { //confirmation 00442 deleteFromDupedMessages( requestMsg ); 00443 delete requestMsg; 00444 } 00445 }
void LobbyServer::processRequestNode | ( | RequestNodeMessage * | requestMsg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00455 { 00456 if( requestMsg->getServiceType() == REQUEST) { 00457 if ( !findOpenCreate(requestMsg->getSubSpaceId(), requestMsg->getNodeType() ) ) { 00458 //CreateNode 00459 CreateNodeMessage* createMsg = new CreateNodeMessage("CreateNodeCauseofRequest"); 00460 createMsg->setCommand(CREATE); 00461 createMsg->setServiceType(REQUEST); 00462 createMsg->setNodeType( requestMsg->getNodeType() ); 00463 createMsg->setJobType( CREATENODE ); 00464 createMsg->setSubSpaceToCreate( *(subSpaceTable->getSubSpace(requestMsg->getSubSpaceId())) ); 00465 00466 if ( requestMsg->getNodeType() == BACKUPNODE ) { 00467 // Send the old one a delete... 00468 CreateNodeMessage* backupCreate = new CreateNodeMessage("BackupDeleteMsg"); 00469 backupCreate->setCommand(CREATE); 00470 backupCreate->setServiceType(REQUEST); 00471 backupCreate->setNodeType(BACKUPNODE); 00472 backupCreate->setSubSpaceToCreate( *(subSpaceTable->getSubSpace(requestMsg->getSubSpaceId())) ); 00473 backupCreate->setJobType(DELETENODE); 00474 sendMsg(backupCreate, subSpaceTable->getSubSpace(requestMsg->getSubSpaceId() )->getBackupIp() ); 00475 } 00476 sendMsg( createMsg, (playerOnlineTable->getHeadAndModify(requestMsg->getSubSpaceId(), requestMsg->getSrcip(), -110 )).getIp() ); 00477 } 00478 requestMsg->setServiceType(CONFIRMATION); 00479 sendMsg( requestMsg, requestMsg->getSrcip() ); 00480 } 00481 else { 00482 delete requestMsg; 00483 } 00484 }
void LobbyServer::processUpdateRespIp | ( | UpdateRespIpMessage * | updateMsg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00448 { 00449 if( updateMsg->getServiceType() == CONFIRMATION ) { 00450 deleteFromDupedMessages( updateMsg); 00451 delete updateMsg; 00452 } 00453 }
void LobbyServer::processReplacement | ( | ReplacementMessage * | replaceMsg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00487 { 00488 //send old responsible Node a delete msg 00489 CreateNodeMessage* deleteCreate = new CreateNodeMessage("deleteOldResponsibleNode"); 00490 deleteCreate->setCommand(CREATE); 00491 deleteCreate->setServiceType(REQUEST); 00492 deleteCreate->setNodeType(RESPONSIBLENODE); 00493 deleteCreate->setJobType(DELETENODE); 00494 deleteCreate->setSubSpaceToCreate(*(subSpaceTable->getSubSpace(replaceMsg->getSubSpaceId())) ); 00495 if( replaceMsg->getSrcip() != subSpaceTable->getSubSpace(replaceMsg->getSubSpaceId())->getRespIp() ) { 00496 sendMsg( deleteCreate, subSpaceTable->getSubSpace(replaceMsg->getSubSpaceId())->getRespIp() ); 00497 } 00498 else { delete deleteCreate; } 00499 //missing 00500 subSpaceTable->setResponsibleNode(replaceMsg->getSubSpaceId() , replaceMsg->getSrcip() ); 00501 informNeighbors( subSpaceTable->getSubSpace(replaceMsg->getSubSpaceId()) ); 00502 // Get a new Backup Node 00503 CreateNodeMessage* backupCreate = new CreateNodeMessage( "backupCreateCauseOfReplacement" ); 00504 backupCreate->setCommand(CREATE); 00505 backupCreate->setServiceType(REQUEST); 00506 backupCreate->setNodeType(BACKUPNODE); 00507 backupCreate->setJobType(CREATENODE); 00508 backupCreate->setSubSpaceToCreate(*(subSpaceTable->getSubSpace(replaceMsg->getSubSpaceId())) ); 00509 sendMsg( backupCreate,(playerOnlineTable->getHeadAndModify(replaceMsg->getSubSpaceId(), replaceMsg->getSrcip(), -110 )).getIp() ); 00510 //Confirm 00511 replaceMsg->setServiceType(CONFIRMATION); 00512 sendMsg(replaceMsg, replaceMsg->getSrcip() ); 00513 }
void LobbyServer::processPing | ( | PingMessage * | pingMsg | ) | [private, virtual] |
We use only Request/confirmation
Reimplemented from YMMOGBase.
00138 { 00142 deleteFromOpenPings(pingMsg->getSrcip()); 00143 delete pingMsg; 00144 }
void LobbyServer::processStabilize | ( | StabilizeMessage * | smsg | ) | [private, virtual] |
Reimplemented from YMMOGBase.
00515 { 00516 SubSpace* subSpace = subSpaceTable->getSubSpace( stabilizeMsg->getSubSpaceId() ); 00517 if( stabilizeMsg->getNodeType() == RESPONSIBLENODE) { 00518 if( subSpace->getRespIp() == stabilizeMsg->getSrcip() ) { 00519 stabilizeMsg->setCorrect(true); 00520 } 00521 } 00522 else if ( stabilizeMsg->getNodeType() == BACKUPNODE ) { 00523 if( subSpace->getBackupIp() == stabilizeMsg->getSrcip() ) { 00524 stabilizeMsg->setCorrect(true); 00525 } 00526 } 00527 stabilizeMsg->setSubSpace( *subSpace); 00528 stabilizeMsg->setServiceType(RESPONSE); 00529 sendMsg( stabilizeMsg, stabilizeMsg->getSrcip() ); 00530 }
PlayerTable* LobbyServer::playerOnlineTable [private] |
SubSpaceTable* LobbyServer::subSpaceTable [private] |
int LobbyServer::gameSpaceSize [private] |
int LobbyServer::subSpaceSize [private] |
int LobbyServer::maxFailedPings [private] |
int LobbyServer::completedLogins [private] |
bool LobbyServer::thereIsANotReadyCreate [private] |