nDescriptor Class Reference

#include <nNetwork.h>

Inheritance diagram for nDescriptor:

Inheritance graph
[legend]
Collaboration diagram for nDescriptor:

Collaboration graph
[legend]

List of all members.

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
nHandlerhandler
const char * name
const bool acceptWithoutLogin

Static Private Attributes

static unsigned short s_nextID

Friends

class nMessage


Detailed Description

Definition at line 382 of file nNetwork.h.


Constructor & Destructor Documentation

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;


Member Function Documentation

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 

Here is the call graph for this function:

Here is the caller graph for this function:

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     }

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nMessage [friend]

Definition at line 383 of file nNetwork.h.


Member Data Documentation

unsigned short nDescriptor::s_nextID [static, private]

Definition at line 385 of file nNetwork.h.

Referenced by nDescriptor().

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]

Definition at line 388 of file nNetwork.h.

Referenced by HandleMessage().

const char* nDescriptor::name [private]

Definition at line 390 of file nNetwork.h.

const bool nDescriptor::acceptWithoutLogin [private]

Definition at line 392 of file nNetwork.h.

Referenced by HandleMessage().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:47:29 2008 for Armagetron Advanced by  doxygen 1.5.4