aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/login__server_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/login__server_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/login__server_8cpp-source.html539
1 files changed, 539 insertions, 0 deletions
diff --git a/docs/doxygen/nel/login__server_8cpp-source.html b/docs/doxygen/nel/login__server_8cpp-source.html
new file mode 100644
index 00000000..cd0035e2
--- /dev/null
+++ b/docs/doxygen/nel/login__server_8cpp-source.html
@@ -0,0 +1,539 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>login_server.cpp</h1><a href="login__server_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00008 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
+00009 <font class="comment"> *</font>
+00010 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00011 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00012 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00013 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00014 <font class="comment"> * any later version.</font>
+00015 <font class="comment"></font>
+00016 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00017 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00018 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00019 <font class="comment"> * General Public License for more details.</font>
+00020 <font class="comment"></font>
+00021 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00022 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00023 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00024 <font class="comment"> * MA 02111-1307, USA.</font>
+00025 <font class="comment"> */</font>
+00026
+00027 <font class="preprocessor">#include "<a class="code" href="stdnet_8h.html">stdnet.h</a>"</font>
+00028
+00029 <font class="preprocessor">#include "<a class="code" href="callback__client_8h.html">nel/net/callback_client.h</a>"</font>
+00030 <font class="preprocessor">#include "<a class="code" href="service_8h.html">nel/net/service.h</a>"</font>
+00031
+00032 <font class="preprocessor">#include "<a class="code" href="login__cookie_8h.html">nel/net/login_cookie.h</a>"</font>
+00033 <font class="preprocessor">#include "<a class="code" href="login__server_8h.html">nel/net/login_server.h</a>"</font>
+00034
+00035 <font class="preprocessor">#include "<a class="code" href="udp__sock_8h.html">nel/net/udp_sock.h</a>"</font>
+00036
+00037 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00038 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
+00039
+00040 <font class="keyword">namespace </font>NLNET {
+00041
+<a name="l00042"></a><a class="code" href="structNLNET_1_1CPendingUser.html">00042</a> <font class="keyword">struct </font>CPendingUser
+00043 {
+<a name="l00044"></a><a class="code" href="structNLNET_1_1CPendingUser.html#a0">00044</a> <a class="code" href="structNLNET_1_1CPendingUser.html#a0">CPendingUser</a> (<font class="keyword">const</font> CLoginCookie &amp;cookie) : <a class="code" href="structNLNET_1_1CPendingUser.html#m0">Cookie</a> (cookie) { }
+<a name="l00045"></a><a class="code" href="structNLNET_1_1CPendingUser.html#m0">00045</a> CLoginCookie <a class="code" href="structNLNET_1_1CPendingUser.html#m0">Cookie</a>;
+00046 };
+00047
+00048 <font class="keyword">static</font> list&lt;CPendingUser&gt; <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>;
+00049
+00050 <font class="keyword">static</font> CCallbackServer *<a class="code" href="namespaceNLNET.html#a44">Server</a>;
+00051 <font class="keyword">static</font> string <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>;
+00052
+00053 <font class="keyword">static</font> <a class="code" href="namespaceNLNET.html#a11">TDisconnectClientCallback</a> <a class="code" href="namespaceNLNET.html#a46">DisconnectClientCallback</a> = NULL;
+00054
+00056 map&lt;uint32, TSockId&gt; <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>;
+00057
+00058 <a class="code" href="namespaceNLNET.html#a10">TNewClientCallback</a> <a class="code" href="namespaceNLNET.html#a48">NewClientCallback</a> = NULL;
+00059
+00065
+00066 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a104">cbWSChooseShard</a> (CMessage &amp;msgin, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, CCallbackNetBase &amp;netbase)
+00067 {
+00068 <font class="comment">// the WS call me that a new client want to come in my shard</font>
+00069 string reason;
+00070 CLoginCookie cookie;
+00071
+00072 <font class="comment">//</font>
+00073 <font class="comment">// S08: receive "CS" message from WS and send "SCS" message to WS</font>
+00074 <font class="comment">//</font>
+00075
+00076 msgin.serial (cookie);
+00077
+00078 list&lt;CPendingUser&gt;::iterator it;
+00079 <font class="keywordflow">for</font> (it = <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.begin(); it != <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.end (); it++)
+00080 {
+00081 <font class="keywordflow">if</font> ((*it).Cookie == cookie)
+00082 {
+00083 <font class="comment">// the cookie already exists, erase it and return false</font>
+00084 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"cookie %s is already in the pending user list"</font>, cookie.toString().c_str());
+00085 <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.erase (it);
+00086 reason = <font class="stringliteral">"cookie already exists"</font>;
+00087 <font class="keywordflow">break</font>;
+00088 }
+00089 }
+00090 <font class="keywordflow">if</font> (it == <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.end ())
+00091 {
+00092 <font class="comment">// add it to the awaiting client</font>
+00093 <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.push_back (CPendingUser (cookie));
+00094 reason = <font class="stringliteral">""</font>;
+00095 }
+00096
+00097 CMessage msgout (CNetManager::getSIDA (<font class="stringliteral">"WS"</font>), <font class="stringliteral">"SCS"</font>);
+00098 msgout.serial (reason);
+00099 msgout.serial (cookie);
+00100 msgout.serial (<a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>);
+00101 CNetManager::send (<font class="stringliteral">"WS"</font>, msgout);
+00102 }
+00103
+00104 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a105">cbWSChooseShard5</a> (CMessage &amp;msgin, <font class="keyword">const</font> std::string &amp;serviceName, <a class="code" href="types__nl_8h.html#a8">uint16</a> sid)
+00105 {
+00106 <font class="comment">// the WS call me that a new client want to come in my shard</font>
+00107 string reason;
+00108 CLoginCookie cookie;
+00109
+00110 <font class="comment">//</font>
+00111 <font class="comment">// S08: receive "CS" message from WS and send "SCS" message to WS</font>
+00112 <font class="comment">//</font>
+00113
+00114 msgin.serial (cookie);
+00115
+00116 list&lt;CPendingUser&gt;::iterator it;
+00117 <font class="keywordflow">for</font> (it = <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.begin(); it != <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.end (); it++)
+00118 {
+00119 <font class="keywordflow">if</font> ((*it).Cookie == cookie)
+00120 {
+00121 <font class="comment">// the cookie already exists, erase it and return false</font>
+00122 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"cookie %s is already in the pending user list"</font>, cookie.toString().c_str());
+00123 <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.erase (it);
+00124 reason = <font class="stringliteral">"cookie already exists"</font>;
+00125 <font class="keywordflow">break</font>;
+00126 }
+00127 }
+00128 <font class="keywordflow">if</font> (it == <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.end ())
+00129 {
+00130 <font class="comment">// add it to the awaiting client</font>
+00131 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"New cookie %s inserted in the pending user list (awaiting new client)"</font>, cookie.toString().c_str());
+00132 <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.push_back (CPendingUser (cookie));
+00133 reason = <font class="stringliteral">""</font>;
+00134 }
+00135
+00136 CMessage msgout (<font class="stringliteral">"SCS"</font>);
+00137 msgout.serial (reason);
+00138 msgout.serial (cookie);
+00139 msgout.serial (<a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>);
+00140 CUnifiedNetwork::getInstance()-&gt;send (<font class="stringliteral">"WS"</font>, msgout);
+00141 }
+00142
+00143 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a106">cbWSDisconnectClient5</a> (CMessage &amp;msgin, <font class="keyword">const</font> std::string &amp;serviceName, <a class="code" href="types__nl_8h.html#a8">uint16</a> sid)
+00144 {
+00145 <font class="comment">// the WS tells me that i have to disconnect a client</font>
+00146
+00147 <a class="code" href="types__nl_8h.html#a10">uint32</a> userid;
+00148 msgin.serial (userid);
+00149
+00150 map&lt;uint32, TSockId&gt;::iterator it = <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>.find (userid);
+00151 <font class="keywordflow">if</font> (it == <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>.end ())
+00152 {
+00153 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Can't disconnect the user %d, he is not found"</font>, userid);
+00154 }
+00155 <font class="keywordflow">else</font>
+00156 {
+00157 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Disconnect the user %d"</font>, userid);
+00158 <a class="code" href="namespaceNLNET.html#a44">Server</a>-&gt;<a class="code" href="classNLNET_1_1CCallbackServer.html#a7">disconnect</a> ((*it).second);
+00159 }
+00160
+00161 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a46">DisconnectClientCallback</a> != NULL)
+00162 {
+00163 <a class="code" href="namespaceNLNET.html#a46">DisconnectClientCallback</a> (userid);
+00164 }
+00165 }
+00166
+00167 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a107">cbWSDisconnectClient</a> (CMessage &amp;msgin, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, CCallbackNetBase &amp;netbase)
+00168 {
+00169 <a class="code" href="namespaceNLNET.html#a106">cbWSDisconnectClient5</a> (msgin, <font class="stringliteral">""</font>, 0);
+00170 }
+00171
+00172 <font class="keyword">static</font> TCallbackItem <a class="code" href="namespaceNLNET.html#a49">WSCallbackArray</a>[] =
+00173 {
+00174 { <font class="stringliteral">"CS"</font>, <a class="code" href="namespaceNLNET.html#a104">cbWSChooseShard</a> },
+00175 { <font class="stringliteral">"DC"</font>, <a class="code" href="namespaceNLNET.html#a107">cbWSDisconnectClient</a> },
+00176 };
+00177
+00178 <font class="keyword">static</font> TUnifiedCallbackItem <a class="code" href="namespaceNLNET.html#a50">WSCallbackArray5</a>[] =
+00179 {
+00180 { <font class="stringliteral">"CS"</font>, <a class="code" href="namespaceNLNET.html#a105">cbWSChooseShard5</a> },
+00181 { <font class="stringliteral">"DC"</font>, <a class="code" href="namespaceNLNET.html#a106">cbWSDisconnectClient5</a> },
+00182 };
+00183
+00189
+00190 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a108">cbShardValidation</a> (CMessage &amp;msgin, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, CCallbackNetBase &amp;netbase)
+00191 {
+00192 <font class="comment">//</font>
+00193 <font class="comment">// S13: receive "SV" message from client</font>
+00194 <font class="comment">//</font>
+00195
+00196 <font class="comment">// the client send me a cookie</font>
+00197 CLoginCookie cookie;
+00198 string reason;
+00199 msgin.serial (cookie);
+00200
+00201 <font class="comment">// verify that the user was pending</font>
+00202 reason = CLoginServer::isValidCookie (cookie);
+00203
+00204 CMessage msgout2 (netbase.getSIDA (), <font class="stringliteral">"SV"</font>);
+00205 msgout2.serial (reason);
+00206 netbase.send (msgout2, from);
+00207
+00208 <font class="keywordflow">if</font> (!reason.empty())
+00209 {
+00210 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"User (%s) is not in the pending user list (cookie:%s)"</font>, netbase.hostAddress(from).asString().c_str(), cookie.toString().c_str());
+00211 <font class="comment">// deconnect him</font>
+00212 netbase.disconnect (from);
+00213 }
+00214 <font class="keywordflow">else</font>
+00215 {
+00216 <font class="comment">// add the user association</font>
+00217 <a class="code" href="types__nl_8h.html#a10">uint32</a> userid = cookie.getUserId();
+00218 <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>.insert (make_pair(userid, from));
+00219
+00220 <font class="comment">// identification OK, let's call the user callback</font>
+00221 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a48">NewClientCallback</a> != NULL)
+00222 <a class="code" href="namespaceNLNET.html#a48">NewClientCallback</a> (from, cookie);
+00223
+00224 <font class="comment">// ok, now, he can call all callback</font>
+00225 <a class="code" href="namespaceNLNET.html#a44">Server</a>-&gt;<a class="code" href="classNLNET_1_1CCallbackNetBase.html#a11">authorizeOnly</a> (NULL, from);
+00226 }
+00227 }
+00228
+00229 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a109">ClientConnection</a> (<a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, <font class="keywordtype">void</font> *arg)
+00230 {
+00231 <a class="code" href="debug_8h.html#a0">nldebug</a>(<font class="stringliteral">"new client connection: %s"</font>, from-&gt;asString ().c_str ());
+00232
+00233 <font class="comment">// the client could only call "SV" message</font>
+00234 <a class="code" href="namespaceNLNET.html#a44">Server</a>-&gt;<a class="code" href="classNLNET_1_1CCallbackNetBase.html#a11">authorizeOnly</a> (<font class="stringliteral">"SV"</font>, from);
+00235 }
+00236
+00237
+00238 <font class="keyword">static</font> <font class="keyword">const</font> TCallbackItem <a class="code" href="namespaceNLNET.html#a51">ClientCallbackArray</a>[] =
+00239 {
+00240 { <font class="stringliteral">"SV"</font>, <a class="code" href="namespaceNLNET.html#a108">cbShardValidation</a> },
+00241 };
+00242
+00243 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a110">cfcbListenAddress</a> (CConfigFile::CVar &amp;var)
+00244 {
+00245 <font class="comment">// set the new ListenAddr</font>
+00246 <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a> = var.asString();
+00247
+00248 <font class="comment">// is the var is empty or not found, take it from the listenAddress()</font>
+00249 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>.empty())
+00250 {
+00251 <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a> = <a class="code" href="namespaceNLNET.html#a44">Server</a>-&gt;<a class="code" href="classNLNET_1_1CBufServer.html#a13">listenAddress</a> ().<a class="code" href="classNLNET_1_1CInetAddress.html#a18">asIPString</a>();
+00252 }
+00253
+00254 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"Listen Address trapped '%s'"</font>, <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>.c_str());
+00255 }
+00256
+00257
+00263
+<a name="l00264"></a><a class="code" href="classNLNET_1_1CLoginServer.html#d0">00264</a> <font class="keywordtype">void</font> CLoginServer::init (CCallbackServer &amp;server, <a class="code" href="namespaceNLNET.html#a10">TNewClientCallback</a> ncl)
+00265 {
+00266 <font class="comment">// connect to the welcome service</font>
+00267 <a class="code" href="classNLNET_1_1CLoginServer.html#f0">connectToWS</a> ();
+00268
+00269 <font class="comment">// add callback to the server</font>
+00270 server.addCallbackArray (<a class="code" href="namespaceNLNET.html#a51">ClientCallbackArray</a>, <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a51">ClientCallbackArray</a>) / <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a51">ClientCallbackArray</a>[0]));
+00271 server.setConnectionCallback (<a class="code" href="namespaceNLNET.html#a109">ClientConnection</a>, NULL);
+00272
+00273 <font class="keywordflow">try</font>
+00274 {
+00275 <a class="code" href="namespaceNLNET.html#a110">cfcbListenAddress</a> (IService::getInstance()-&gt;ConfigFile.getVar(<font class="stringliteral">"ListenAddress"</font>));
+00276 IService::getInstance()-&gt;ConfigFile.setCallback(<font class="stringliteral">"ListenAddress"</font>, <a class="code" href="namespaceNLNET.html#a110">cfcbListenAddress</a>);
+00277 }
+00278 <font class="keywordflow">catch</font>(Exception &amp;)
+00279 {
+00280 }
+00281
+00282 <font class="comment">// if the listen addr is not in the config file, try to find it dynamically</font>
+00283 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>.empty())
+00284 {
+00285 <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a> = server.listenAddress ().asIPString();
+00286 }
+00287
+00288 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"Listen Address trapped '%s'"</font>, <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>.c_str());
+00289
+00290 <a class="code" href="namespaceNLNET.html#a48">NewClientCallback</a> = ncl;
+00291 <a class="code" href="namespaceNLNET.html#a44">Server</a> = &amp;server;
+00292 }
+00293
+<a name="l00294"></a><a class="code" href="classNLNET_1_1CLoginServer.html#d1">00294</a> <font class="keywordtype">void</font> CLoginServer::init (CUdpSock &amp;server, <a class="code" href="namespaceNLNET.html#a11">TDisconnectClientCallback</a> dc)
+00295 {
+00296 <font class="comment">// connect to the welcome service</font>
+00297 <a class="code" href="classNLNET_1_1CLoginServer.html#f0">connectToWS</a> ();
+00298
+00299 <font class="keywordflow">try</font>
+00300 {
+00301 <a class="code" href="namespaceNLNET.html#a110">cfcbListenAddress</a> (IService::getInstance()-&gt;ConfigFile.getVar(<font class="stringliteral">"ListenAddress"</font>));
+00302 IService::getInstance()-&gt;ConfigFile.setCallback(<font class="stringliteral">"ListenAddress"</font>, <a class="code" href="namespaceNLNET.html#a110">cfcbListenAddress</a>);
+00303 }
+00304 <font class="keywordflow">catch</font>(Exception &amp;)
+00305 {
+00306 }
+00307
+00308 <font class="comment">// if the listen addr is not in the config file, try to find it dynamically</font>
+00309 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>.empty())
+00310 {
+00311 <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a> = server.localAddr ().asIPString();
+00312 }
+00313
+00314 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"Listen Addresss trapped '%s'"</font>, <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>.c_str());
+00315
+00316 <a class="code" href="namespaceNLNET.html#a46">DisconnectClientCallback</a> = dc;
+00317 }
+00318
+00319 string CLoginServer::isValidCookie (<font class="keyword">const</font> CLoginCookie &amp;lc)
+00320 {
+00321 <font class="comment">// verify that the user was pending</font>
+00322 list&lt;CPendingUser&gt;::iterator it;
+00323 <font class="keywordflow">for</font> (it = <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.begin(); it != <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.end (); it++)
+00324 {
+00325 <font class="keywordflow">if</font> ((*it).Cookie == lc)
+00326 {
+00327 <font class="comment">// ok, it was validate, remove it</font>
+00328 <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.erase (it);
+00329
+00330 <font class="comment">// warn the WS that the client effectively connected</font>
+00331 <a class="code" href="types__nl_8h.html#a6">uint8</a> con = 1;
+00332 CMessage msgout (<font class="stringliteral">"CC"</font>);
+00333 <a class="code" href="types__nl_8h.html#a10">uint32</a> userid = lc.getUserId();
+00334 msgout.serial (userid);
+00335 msgout.serial (con);
+00336
+00337 <font class="keywordflow">if</font> (CUnifiedNetwork::isUsed ())
+00338 {
+00339 CUnifiedNetwork::getInstance()-&gt;send(<font class="stringliteral">"WS"</font>, msgout);
+00340 }
+00341 <font class="keywordflow">else</font>
+00342 {
+00343 CNetManager::send(<font class="stringliteral">"WS"</font>, msgout);
+00344 }
+00345
+00346 <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
+00347 }
+00348 }
+00349 <font class="keywordflow">return</font> <font class="stringliteral">"I didn't receive the cookie from WS"</font>;
+00350 }
+00351
+<a name="l00352"></a><a class="code" href="classNLNET_1_1CLoginServer.html#f0">00352</a> <font class="keywordtype">void</font> CLoginServer::connectToWS ()
+00353 {
+00354 <font class="keywordflow">if</font> (CUnifiedNetwork::isUsed ())
+00355 {
+00356 CUnifiedNetwork::getInstance()-&gt;addCallbackArray(<a class="code" href="namespaceNLNET.html#a50">WSCallbackArray5</a>, <font class="keyword">sizeof</font>(<a class="code" href="namespaceNLNET.html#a50">WSCallbackArray5</a>)/<font class="keyword">sizeof</font>(<a class="code" href="namespaceNLNET.html#a50">WSCallbackArray5</a>[0]));
+00357 }
+00358 <font class="keywordflow">else</font>
+00359 {
+00360 CNetManager::addClient (<font class="stringliteral">"WS"</font>);
+00361 CNetManager::addCallbackArray (<font class="stringliteral">"WS"</font>, <a class="code" href="namespaceNLNET.html#a49">WSCallbackArray</a>, <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a49">WSCallbackArray</a>) / <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a49">WSCallbackArray</a>[0]));
+00362
+00363 CMessage msg(<font class="stringliteral">"UN_SIDENT"</font>);
+00364 <a class="code" href="debug_8h.html#a6">nlassert</a> (IService::getInstance());
+00365 <a class="code" href="types__nl_8h.html#a8">uint16</a> ssid = IService::getInstance()-&gt;getServiceId();
+00366 string name = IService::getInstance()-&gt;getServiceShortName();
+00367 msg.serial(name);
+00368 msg.serial(ssid); <font class="comment">// serializes a 16 bits service id</font>
+00369 CNetManager::send(<font class="stringliteral">"WS"</font>, msg);
+00370 }
+00371 }
+00372
+<a name="l00373"></a><a class="code" href="classNLNET_1_1CLoginServer.html#d3">00373</a> <font class="keywordtype">void</font> CLoginServer::clientDisconnected (<a class="code" href="types__nl_8h.html#a10">uint32</a> userId)
+00374 {
+00375 <a class="code" href="types__nl_8h.html#a6">uint8</a> con = 0;
+00376 CMessage msgout (<font class="stringliteral">"CC"</font>);
+00377 msgout.serial (userId);
+00378 msgout.serial (con);
+00379
+00380 <font class="keywordflow">if</font> (CUnifiedNetwork::isUsed ())
+00381 {
+00382 CUnifiedNetwork::getInstance()-&gt;send(<font class="stringliteral">"WS"</font>, msgout);
+00383 }
+00384 <font class="keywordflow">else</font>
+00385 {
+00386 CNetManager::send(<font class="stringliteral">"WS"</font>, msgout);
+00387 }
+00388
+00389 <font class="comment">// remove the user association</font>
+00390 <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>.erase (userId);
+00391 }
+00392
+00393 <font class="comment">//</font>
+00394 <font class="comment">// Commands</font>
+00395 <font class="comment">//</font>
+00396
+00397 <a class="code" href="namespaceNLNET.html#a115">NLMISC_COMMAND</a> (lsUsers, <font class="stringliteral">"displays the list of all connected users"</font>, <font class="stringliteral">""</font>)
+00398 {
+00399 <font class="keywordflow">if</font>(args.size() != 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00400
+00401 log.displayNL (<font class="stringliteral">"Display the %d connected users :"</font>, <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>.size());
+00402 <font class="keywordflow">for</font> (map&lt;uint32, TSockId&gt;::iterator it = <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>.begin(); it != <a class="code" href="namespaceNLNET.html#a47">UserIdSockAssociations</a>.end (); it++)
+00403 {
+00404 log.displayNL (<font class="stringliteral">"&gt; %u %s"</font>, (*it).first, (*it).second-&gt;asString().c_str());
+00405 }
+00406 log.displayNL (<font class="stringliteral">"End ot the list"</font>);
+00407
+00408 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00409 }
+00410
+00411 <a class="code" href="namespaceNLNET.html#a115">NLMISC_COMMAND</a> (lsPending, <font class="stringliteral">"displays the list of all pending users"</font>, <font class="stringliteral">""</font>)
+00412 {
+00413 <font class="keywordflow">if</font>(args.size() != 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00414
+00415 log.displayNL (<font class="stringliteral">"Display the %d pending users :"</font>, <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.size());
+00416 <font class="keywordflow">for</font> (list&lt;CPendingUser&gt;::iterator it = <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.begin(); it != <a class="code" href="namespaceNLNET.html#a43">PendingUsers</a>.end (); it++)
+00417 {
+00418 log.displayNL (<font class="stringliteral">"&gt; %s"</font>, (*it).Cookie.toString().c_str());
+00419 }
+00420 log.displayNL (<font class="stringliteral">"End ot the list"</font>);
+00421
+00422 <font class="keywordflow">return</font> <font class="keyword">true</font>;
+00423 }
+00424
+00425
+00426 <a class="code" href="namespaceNLNET.html#a134">NLMISC_DYNVARIABLE</a>(string, LSListenAddress, <font class="stringliteral">"the listen address sended to the client to connect on this front_end"</font>)
+00427 {
+00428 <font class="keywordflow">if</font> (get)
+00429 {
+00430 *<a class="code" href="driver__opengl__extension__def_8h.html#a240">pointer</a> = <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>;
+00431 }
+00432 <font class="keywordflow">else</font>
+00433 {
+00434 <font class="keywordflow">if</font> ((*pointer).find (<font class="stringliteral">":"</font>) == string::npos)
+00435 {
+00436 log.displayNL (<font class="stringliteral">"You must set the address + port (ie: \"itsalive.nevrax.org:38000\")"</font>);
+00437 <font class="keywordflow">return</font>;
+00438 }
+00439 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*pointer).empty())
+00440 {
+00441 <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a> = <a class="code" href="namespaceNLNET.html#a44">Server</a>-&gt;<a class="code" href="classNLNET_1_1CBufServer.html#a13">listenAddress</a> ().<a class="code" href="classNLNET_1_1CInetAddress.html#a18">asIPString</a>();
+00442 }
+00443 <font class="keywordflow">else</font>
+00444 {
+00445 <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a> = *<a class="code" href="driver__opengl__extension__def_8h.html#a240">pointer</a>;
+00446 }
+00447 log.displayNL (<font class="stringliteral">"Listen Address trapped '%s'"</font>, <a class="code" href="namespaceNLNET.html#a45">ListenAddr</a>.c_str());
+00448 }
+00449 }
+00450
+00451
+00452 } <font class="comment">// NLNET</font>
+00453
+00454
+00458 <font class="comment">/*</font>
+00459 <font class="comment">#include "v2/service.h"</font>
+00460 <font class="comment"></font>
+00461 <font class="comment">using namespace std;</font>
+00462 <font class="comment">using namespace NLNET;</font>
+00463 <font class="comment"></font>
+00464 <font class="comment">void ClientConnection (TSockId from, const CLoginCookie &amp;cookie)</font>
+00465 <font class="comment">{</font>
+00466 <font class="comment"> nlinfo("player (%d) comes in", cookie.getUserId());</font>
+00467 <font class="comment"> from-&gt;setAppId (cookie.getUserId());</font>
+00468 <font class="comment">}</font>
+00469 <font class="comment"></font>
+00470 <font class="comment">void ClientDisconnection (TSockId from, void *arg)</font>
+00471 <font class="comment">{</font>
+00472 <font class="comment"> nlinfo("player (%d) leaves", from-&gt;appId());</font>
+00473 <font class="comment"> CLoginServer::clientDisconnected (from-&gt;appId());</font>
+00474 <font class="comment"></font>
+00475 <font class="comment">}</font>
+00476 <font class="comment"></font>
+00477 <font class="comment">class CFrontEndService : public NLNET::IService</font>
+00478 <font class="comment">{</font>
+00479 <font class="comment">public:</font>
+00480 <font class="comment"></font>
+00482 <font class="comment"> void init ()</font>
+00483 <font class="comment"> {</font>
+00484 <font class="comment"> CLoginServer::init (dynamic_cast&lt;CCallbackServer&amp;&gt;(*CNetManager::getNetBase ("FES")), ClientConnection);</font>
+00485 <font class="comment"> CNetManager::getNetBase ("FES")-&gt;setDisconnectionCallback (ClientDisconnection, NULL);</font>
+00486 <font class="comment"> }</font>
+00487 <font class="comment">};</font>
+00488 <font class="comment"></font>
+00489 <font class="comment"></font>
+00491 <font class="comment">NLNET_SERVICE_MAIN (CFrontEndService, "FES", "front_end_service", 0);</font>
+00492 <font class="comment">*/</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>