NLNET::CLoginServer Class Reference

#include <login_server.h>


Detailed Description

This class is the server part of the Login System. It is used in the Front End Service. At the begining, it connects to the WS. When a new player comes in and is authenticated, a callback is called to warn the user code that a new player is here. Example:
Author:
Vianney Lecroart

Nevrax France

Date:
2001

Definition at line 65 of file login_server.h.

Static Public Member Functions

void clientDisconnected (uint32 userId)
std::string CLoginServer::isValidCookie (const CLoginCookie &lc, std::string &userName, std::string &userPriv)
 Used only in UDP, check if the cookie is valid. return empty string if valid, reason otherwise.

void init (CUdpSock &server, TDisconnectClientCallback dc)
void init (CCallbackServer &server, TNewClientCallback ncl)

Static Private Member Functions

void connectToWS ()
 This function is used by init() to create the connection to the Welcome Service.

void init (const std::string &listenAddress)


Member Function Documentation

void NLNET::CLoginServer::clientDisconnected uint32  userId  )  [static]
 

Call this method when a user is disconnected or the server disconnect the user. This method will warn the login system that the user is not here anymore

Definition at line 413 of file login_server.cpp.

References NLNET::ModeTcp, NLMISC::CMemStream::serial(), uint32, uint8, and NLNET::UserIdSockAssociations.

00414 {
00415         uint8 con = 0;
00416         CMessage msgout ("CC");
00417         msgout.serial (userId);
00418         msgout.serial (con);
00419 
00420         CUnifiedNetwork::getInstance()->send("WS", msgout);
00421 
00422         // remove the user association
00423         if (ModeTcp)
00424                 UserIdSockAssociations.erase (userId);
00425 }

std::string NLNET::CLoginServer::CLoginServer::isValidCookie const CLoginCookie lc,
std::string &  userName,
std::string &  userPriv
[static]
 

Used only in UDP, check if the cookie is valid. return empty string if valid, reason otherwise.

void NLNET::CLoginServer::connectToWS  )  [static, private]
 

This function is used by init() to create the connection to the Welcome Service.

Definition at line 408 of file login_server.cpp.

References NLNET::WSCallbackArray.

Referenced by init().

00409 {
00410         CUnifiedNetwork::getInstance()->addCallbackArray(WSCallbackArray, sizeof(WSCallbackArray)/sizeof(WSCallbackArray[0]));
00411 }

void NLNET::CLoginServer::init const std::string &  listenAddress  )  [static, private]
 

Definition at line 295 of file login_server.cpp.

References NLNET::cfcbAcceptInvalidCookie(), NLNET::cfcbDefaultUserPriv(), NLNET::cfcbListenAddress(), NLNET::cfcbTimeBeforeEraseCookie(), connectToWS(), and NLNET::setListenAddress().

00296 {
00297         // connect to the welcome service
00298         connectToWS ();
00299         
00300         try {
00301                 cfcbDefaultUserPriv(IService::getInstance()->ConfigFile.getVar("DefaultUserPriv"));
00302                 IService::getInstance()->ConfigFile.setCallback("DefaultUserPriv", cfcbDefaultUserPriv);
00303         } catch(Exception &) { }
00304         
00305         try {
00306                 cfcbAcceptInvalidCookie (IService::getInstance()->ConfigFile.getVar("AcceptInvalidCookie"));
00307                 IService::getInstance()->ConfigFile.setCallback("AcceptInvalidCookie", cfcbAcceptInvalidCookie);
00308         } catch(Exception &) { }
00309 
00310         try {
00311                 cfcbTimeBeforeEraseCookie (IService::getInstance()->ConfigFile.getVar("TimeBeforeEraseCookie"));
00312                 IService::getInstance()->ConfigFile.setCallback("TimeBeforeEraseCookie", cfcbTimeBeforeEraseCookie);
00313         } catch(Exception &) { }
00314 
00315         // setup the listen address
00316 
00317         string la;
00318         
00319         if (IService::getInstance()->haveArg('D'))
00320         {
00321                 // use the command line param if set
00322                 la = IService::getInstance()->getArg('D');
00323         }
00324         else if (IService::getInstance()->ConfigFile.exists ("ListenAddress"))
00325         {
00326                 // use the config file param if set
00327                 la = IService::getInstance()->ConfigFile.getVar ("ListenAddress").asString();
00328         }
00329         else
00330         {
00331                 la = listenAddress;
00332         }
00333         setListenAddress (la);
00334         IService::getInstance()->ConfigFile.setCallback("ListenAddress", cfcbListenAddress);
00335 }

void NLNET::CLoginServer::init CUdpSock server,
TDisconnectClientCallback  dc
[static]
 

Create the connection to the Welcome Service for an UDP connection the dc will be call when the Welcome Service decides to disconnect a player (double login...)

Definition at line 353 of file login_server.cpp.

References NLNET::CInetAddress::asIPString(), NLNET::DisconnectClientCallback, init(), NLNET::CSock::localAddr(), NLNET::ModeTcp, and NLNET::TDisconnectClientCallback.

00354 {
00355         init (server.localAddr ().asIPString());
00356 
00357         DisconnectClientCallback = dc;
00358 
00359         ModeTcp = false;
00360 }

void NLNET::CLoginServer::init CCallbackServer server,
TNewClientCallback  ncl
[static]
 

Create the connection to the Welcome Service and install callbacks to the callback server (for a TCP connection) init() will try to find the ListenAddress in the config file and it will be used to say to the client the address to connect to this frontend (using the login system). You can modify this in real time in the config file or with the ls_listen_address command The ListenAddress must be in the form of "itsalive.nevrax.org:38000" (ip+port)

Definition at line 338 of file login_server.cpp.

References NLNET::CCallbackNetBase::addCallbackArray(), NLNET::CInetAddress::asIPString(), NLNET::ClientCallbackArray, NLNET::ClientConnection(), NLNET::CBufServer::listenAddress(), NLNET::ModeTcp, NLNET::NewClientCallback, NLNET::Server, NLNET::CCallbackServer::setConnectionCallback(), and NLNET::TNewClientCallback.

Referenced by init().

00339 {
00340         init (server.listenAddress ().asIPString());
00341         
00342         // add callback to the server
00343         server.addCallbackArray (ClientCallbackArray, sizeof (ClientCallbackArray) / sizeof (ClientCallbackArray[0]));
00344         server.setConnectionCallback (ClientConnection, NULL);
00345 
00346         NewClientCallback = ncl;
00347         Server = &server;
00348 
00349         ModeTcp = true;
00350 }


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:58:38 2004 for NeL by doxygen 1.3.6