#include <nNetwork.h>
Public Member Functions | |
nDescriptor (unsigned short identification, nHandler *handle, const char *name, bool acceptEvenIfNotLoggedIn=false) | |
unsigned short | ID () |
Static Public Member Functions | |
static void | HandleMessage (nMessage &message) |
Private Attributes | |
unsigned short | id |
nHandler * | handler |
const char * | name |
const bool | acceptWithoutLogin |
Static Private Attributes | |
static unsigned short | s_nextID |
Friends | |
class | nMessage |
Definition at line 382 of file nNetwork.h.
nDescriptor::nDescriptor | ( | unsigned short | identification, | |
nHandler * | handle, | |||
const char * | name, | |||
bool | acceptEvenIfNotLoggedIn = false | |||
) |
Definition at line 535 of file nNetwork.cpp.
References con, id, MAXDESCRIPTORS, NULL, and s_nextID.
00539 :tListItem<nDescriptor>(nDescriptor_anchor), 00540 id(identification),handler(handle),name(Name), acceptWithoutLogin(awl) 00541 { 00542 #ifdef DEBUG 00543 #ifndef WIN32 00544 // con << "Descriptor " << id << ": " << name << '\n'; 00545 #endif 00546 #endif 00547 if (MAXDESCRIPTORS<=id || descriptors[id]!=NULL){ 00548 con << "Descriptor " << id << " already used!\n"; 00549 exit(-1); 00550 } 00551 s_nextID=id+1;
void nDescriptor::HandleMessage | ( | nMessage & | message | ) | [static] |
Definition at line 571 of file nNetwork.cpp.
References acceptWithoutLogin, con, nMessage::Descriptor(), nMessage::descriptor, tException::GetDescription(), tException::GetName(), handler, MAXDESCRIPTORS, nMessage::SenderID(), tOutput::SetTemplateParameter(), sn_ConsoleOut(), and sn_DisconnectUser().
Referenced by rec_peer().
00573 { 00574 static tArray<bool> warned; 00575 00576 // store sender ID for console 00577 nCurrentSenderID currentSender( message.SenderID() ); 00578 00579 #ifdef DEBUG_X 00580 if (message.descriptor>1) 00581 con << "RMT " << message.descriptor << "\n"; 00582 #endif 00583 00584 #ifndef NOEXCEPT 00585 try{ 00586 #endif 00587 nDescriptor *nd = 0; 00588 00589 // z-man: security check ( thanks, Luigi Auriemma! ) 00590 if ( message.descriptor < MAXDESCRIPTORS ) 00591 nd=descriptors[message.descriptor]; 00592 00593 if (nd){ 00594 if ((message.SenderID() <= MAXCLIENTS) || nd->acceptWithoutLogin) 00595 nd->handler(message); 00596 } 00597 else 00598 if (!warned[message.Descriptor()]){ 00599 tOutput warn; 00600 warn.SetTemplateParameter(1, message.Descriptor()); 00601 warn << "$network_warn_unknowndescriptor"; 00602 con << warn; 00603 warned[message.Descriptor()]=true; 00604 } 00605 #ifndef NOEXCEPT 00606 } 00607 catch(nIgnore const &){ 00608 // well, do nothing. 00609 } 00610 catch(nKillHim const &){ 00611 // st_Breakpoint(); 00612 con << tOutput("$network_error"); 00613 sn_DisconnectUser(message.SenderID(), "$network_kill_error" ); 00614 } 00615 catch( tGenericException & e ) 00616 { 00617 // relay generic errors to sender of message; don't do anything else bad. Especially, we don't 00618 // want a harmless uncaught exception to bring down the server. 00619 sn_ConsoleOut( e.GetName() + ": " + e.GetDescription() + '\n', message.SenderID() ); 00620 } 00621
unsigned short nDescriptor::ID | ( | ) | [inline] |
Definition at line 400 of file nNetwork.h.
References id.
Referenced by net_Accept(), nWaitForAck::nWaitForAck(), rec_peer(), and nMessage::Send().
00400 { 00401 return id; 00402 }
friend class nMessage [friend] |
Definition at line 383 of file nNetwork.h.
unsigned short nDescriptor::s_nextID [static, private] |
unsigned short nDescriptor::id [private] |
Definition at line 387 of file nNetwork.h.
Referenced by ID(), nDescriptor(), nMessage::Send(), and nMessage::SendImmediately().
nHandler* nDescriptor::handler [private] |
const char* nDescriptor::name [private] |
Definition at line 390 of file nNetwork.h.
const bool nDescriptor::acceptWithoutLogin [private] |