diff options
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/callback__client_8cpp-source.html | 500 |
1 files changed, 500 insertions, 0 deletions
diff --git a/docs/doxygen/nel/callback__client_8cpp-source.html b/docs/doxygen/nel/callback__client_8cpp-source.html new file mode 100644 index 00000000..6bb05b19 --- /dev/null +++ b/docs/doxygen/nel/callback__client_8cpp-source.html @@ -0,0 +1,500 @@ +<!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> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </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> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </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> + + +<!-- 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> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <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> </center> +<hr><h1>callback_client.cpp</h1><a href="callback__client_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2001 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="stdnet_8h.html">stdnet.h</a>"</font> +00027 +00028 <font class="preprocessor">#include "<a class="code" href="callback__net__base_8h.html">nel/net/callback_net_base.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="callback__client_8h.html">nel/net/callback_client.h</a>"</font> +00030 +00031 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00032 <font class="preprocessor"></font><font class="preprocessor">#include "<a class="code" href="message__recorder_8h.html">nel/net/message_recorder.h</a>"</font> +00033 <font class="preprocessor">#endif</font> +00034 <font class="preprocessor"></font> +00035 +00036 <font class="keyword">namespace </font>NLNET { +00037 +00038 +00039 <font class="comment">/*</font> +00040 <font class="comment"> * Callbacks management</font> +00041 <font class="comment"> */</font> +00042 +00043 <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a89">cbcMessageRecvAllAssociations</a> (CMessage &msgin, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, CCallbackNetBase &netbase) +00044 { +00045 netbase.getSIDA().ignoreAllUnknownId (<font class="keyword">false</font>); +00046 <a class="code" href="namespaceNLNET.html#a90">cbnbMessageRecvAssociations</a> (msgin, from, netbase); +00047 } +00048 +00049 +00050 <font class="keyword">static</font> TCallbackItem <a class="code" href="namespaceNLNET.html#a27">ClientMessageAssociationArray</a>[] = +00051 { +00052 { <font class="stringliteral">"RAA"</font>, <a class="code" href="namespaceNLNET.html#a89">cbcMessageRecvAllAssociations</a> }, +00053 }; +00054 +00055 +00056 <font class="comment">/*</font> +00057 <font class="comment"> * Constructor</font> +00058 <font class="comment"> */</font> +<a name="l00059"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#a0">00059</a> CCallbackClient::CCallbackClient( TRecordingState rec, <font class="keyword">const</font> std::string& recfilename, <font class="keywordtype">bool</font> recordall ) : +00060 CCallbackNetBase( rec, recfilename, recordall ), CBufClient( true, rec==Replay ), SendNextValue(0), ReceiveNextValue(0) +00061 { +00062 CBufClient::setDisconnectionCallback (<a class="code" href="classNLNET_1_1CCallbackNetBase.html#n2">_NewDisconnectionCallback</a>, <font class="keyword">this</font>); +00063 +00064 <font class="comment">// add the callback needed to associate messages with id</font> +00065 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#a7">addCallbackArray</a> (<a class="code" href="namespaceNLNET.html#a27">ClientMessageAssociationArray</a>, <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a27">ClientMessageAssociationArray</a>) / <font class="keyword">sizeof</font> (<a class="code" href="namespaceNLNET.html#a27">ClientMessageAssociationArray</a>[0])); +00066 +00067 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#n3">_InputSIDA</a>.<a class="code" href="classNLMISC_1_1CStringIdArray.html#a10">ignoreAllUnknownId</a> (<font class="keyword">true</font>); +00068 +00069 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#n7">_IsAServer</a> = <font class="keyword">false</font>; +00070 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#n6">_DefaultCallback</a> = NULL; +00071 } +00072 +00073 +00074 <font class="comment">/*</font> +00075 <font class="comment"> * Send a message to the remote host (pushing to its send queue)</font> +00076 <font class="comment"> * Recorded : YES</font> +00077 <font class="comment"> * Replayed : MAYBE</font> +00078 <font class="comment"> */</font> +<a name="l00079"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#a1">00079</a> <font class="keywordtype">void</font> CCallbackClient::send (<font class="keyword">const</font> CMessage &buffer, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> hostid, <font class="keywordtype">bool</font> log) +00080 { +00081 <a class="code" href="debug_8h.html#a6">nlassert</a> (hostid == InvalidSockId); <font class="comment">// should always be InvalidSockId on client</font> +00082 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00083 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CCallbackClient.html#a5">connected</a> ()); +00084 <a class="code" href="debug_8h.html#a6">nlassert</a> (buffer.length() != 0); +00085 <a class="code" href="debug_8h.html#a6">nlassert</a> (buffer.typeIsSet()); +00086 +00087 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#n0">_BytesSent</a> += buffer.length (); +00088 +00089 <font class="comment">// if (log)</font> +00090 { +00092 <font class="comment">// nldebug ("send message number %u", SendNextValue);</font> +00093 } +00094 +00095 <font class="comment">// debug features, we number all packet to be sure that they are all sent and received</font> +00096 <font class="comment">// \todo remove this debug feature when ok</font> +00097 <font class="comment">// fill the number</font> +00098 uint32 *val = (uint32*)buffer.buffer (); +00099 <font class="preprocessor">#ifdef NL_BIG_ENDIAN</font> +00100 <font class="preprocessor"></font> *val = <a class="code" href="stream_8h.html#a1">NLMISC_BSWAP32</a>(<a class="code" href="classNLNET_1_1CCallbackClient.html#o0">SendNextValue</a>); +00101 <font class="preprocessor">#else</font> +00102 <font class="preprocessor"></font> *val = <a class="code" href="classNLNET_1_1CCallbackClient.html#o0">SendNextValue</a>; +00103 <font class="preprocessor">#endif</font> +00104 <font class="preprocessor"></font> <a class="code" href="classNLNET_1_1CCallbackClient.html#o0">SendNextValue</a>++; +00105 +00106 +00107 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00108 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState != <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s2">Replay</a> ) +00109 { +00110 <font class="preprocessor">#endif</font> +00111 <font class="preprocessor"></font> +00112 <font class="comment">// Send</font> +00113 CBufClient::send (buffer); +00114 +00115 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00116 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState == <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s1">Record</a> ) +00117 { +00118 <font class="comment">// Record sent message</font> +00119 _MR_Recorder.recordNext( _MR_UpdateCounter, <a class="code" href="namespaceNLNET.html#a156a12">Sending</a>, hostid, const_cast<CMessage&>(buffer) ); +00120 } +00121 } +00122 <font class="keywordflow">else</font> +00123 { +00125 } +00126 <font class="preprocessor">#endif</font> +00127 <font class="preprocessor"></font>} +00128 +00129 <font class="comment">/*</font> +00130 <font class="comment"> * Force to send all data pending in the send queue.</font> +00131 <font class="comment"> * Recorded : NO</font> +00132 <font class="comment"> * Replayed : NO</font> +00133 <font class="comment"> */</font> +<a name="l00134"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#a2">00134</a> <font class="keywordtype">bool</font> CCallbackClient::flush (<a class="code" href="namespaceNLNET.html#a0">TSockId</a> hostid) +00135 { +00136 <a class="code" href="debug_8h.html#a6">nlassert</a> (hostid == InvalidSockId); <font class="comment">// should always be InvalidSockId on client</font> +00137 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00138 +00139 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00140 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState != <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s2">Replay</a> ) +00141 { +00142 <font class="preprocessor">#endif</font> +00143 <font class="preprocessor"></font> +00144 <font class="comment">// Flush sending (nothing to do in replay mode)</font> +00145 <font class="keywordflow">return</font> CBufClient::flush(); +00146 +00147 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00148 <font class="preprocessor"></font> } +00149 <font class="keywordflow">else</font> +00150 { +00151 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00152 } +00153 <font class="preprocessor">#endif</font> +00154 <font class="preprocessor"></font>} +00155 +00156 +00157 <font class="comment">/*</font> +00158 <font class="comment"> * Updates the network (call this method evenly)</font> +00159 <font class="comment"> * Recorded : YES (in baseUpdate())</font> +00160 <font class="comment"> * Replayed : YES (in baseUpdate())</font> +00161 <font class="comment"> */</font> +<a name="l00162"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#a3">00162</a> <font class="keywordtype">void</font> CCallbackClient::update ( sint32 timeout ) +00163 { +00164 <font class="comment">// nldebug ("L3: Client: update()");</font> +00165 +00166 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00167 +00168 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b1">baseUpdate</a> (timeout); <font class="comment">// first receive</font> +00169 +00170 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00171 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState != <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s2">Replay</a> ) +00172 { +00173 <font class="preprocessor">#endif</font> +00174 <font class="preprocessor"></font> +00175 <font class="comment">// L1-2 Update (nothing to do in replay mode)</font> +00176 CBufClient::update (); <font class="comment">// then send</font> +00177 +00178 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00179 <font class="preprocessor"></font> } +00180 <font class="preprocessor">#endif</font> +00181 <font class="preprocessor"></font>} +00182 +00183 +00184 <font class="comment">/*</font> +00185 <font class="comment"> * Returns true if there are messages to read</font> +00186 <font class="comment"> * Recorded : NO</font> +00187 <font class="comment"> * Replayed : YES</font> +00188 <font class="comment"> */</font> +<a name="l00189"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#c1">00189</a> <font class="keywordtype">bool</font> CCallbackClient::dataAvailable () +00190 { +00191 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00192 +00193 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00194 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState != <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s2">Replay</a> ) +00195 { +00196 <font class="preprocessor">#endif</font> +00197 <font class="preprocessor"></font> +00198 <font class="comment">// Real dataAvailable()</font> +00199 <font class="keywordflow">return</font> CBufClient::dataAvailable (); +00200 +00201 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00202 <font class="preprocessor"></font> } +00203 <font class="keywordflow">else</font> +00204 { +00205 <font class="comment">// Simulated dataAvailable()</font> +00206 <font class="keywordflow">return</font> CCallbackNetBase::replayDataAvailable(); +00207 } +00208 <font class="preprocessor">#endif</font> +00209 <font class="preprocessor"></font>} +00210 +00211 +00212 <font class="comment">/*</font> +00213 <font class="comment"> * Read the next message in the receive queue</font> +00214 <font class="comment"> * Recorded : YES</font> +00215 <font class="comment"> * Replayed : YES</font> +00216 <font class="comment"> */</font> +<a name="l00217"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#c2">00217</a> <font class="keywordtype">void</font> CCallbackClient::receive (CMessage &buffer, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> *hostid) +00218 { +00219 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00220 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CCallbackClient.html#a5">connected</a> ()); +00221 *hostid = InvalidSockId; +00222 +00223 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00224 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState != <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s2">Replay</a> ) +00225 { +00226 <font class="preprocessor">#endif</font> +00227 <font class="preprocessor"></font> +00228 <font class="comment">// Receive</font> +00229 CBufClient::receive (buffer); +00230 +00231 <font class="comment">// debug features, we number all packet to be sure that they are all sent and received</font> +00232 <font class="comment">// \todo remove this debug feature when ok</font> +00233 <font class="preprocessor">#ifdef NL_BIG_ENDIAN</font> +00234 <font class="preprocessor"></font> uint32 val = <a class="code" href="stream_8h.html#a1">NLMISC_BSWAP32</a>(*(uint32*)buffer.buffer ()); +00235 <font class="preprocessor">#else</font> +00236 <font class="preprocessor"></font> uint32 val = *(uint32*)buffer.buffer (); +00237 <font class="preprocessor">#endif</font> +00238 <font class="preprocessor"></font> +00239 <font class="comment">// nldebug ("receive message number %u", val);</font> +00240 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CCallbackClient.html#o1">ReceiveNextValue</a> != val) +00241 { +00242 <a class="code" href="debug_8h.html#a14">nlstopex</a> ((<font class="stringliteral">"LNETL1: !!!LOST A MESSAGE!!! I received the message number %u but I'm waiting the message number %u (cnx %s), warn lecroart@nevrax.com with the log now please"</font>, val, <a class="code" href="classNLNET_1_1CCallbackClient.html#o1">ReceiveNextValue</a>, <a class="code" href="classNLNET_1_1CBufClient.html#a18">id</a>()->asString().c_str())); +00243 <font class="comment">// resync the message number</font> +00244 <a class="code" href="classNLNET_1_1CCallbackClient.html#o1">ReceiveNextValue</a> = val; +00245 } +00246 <a class="code" href="classNLNET_1_1CCallbackClient.html#o1">ReceiveNextValue</a>++; +00247 +00248 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00249 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState == <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s1">Record</a> ) +00250 { +00251 <font class="comment">// Record received message</font> +00252 _MR_Recorder.recordNext( _MR_UpdateCounter, <a class="code" href="namespaceNLNET.html#a156a13">Receiving</a>, *hostid, const_cast<CMessage&>(buffer) ); +00253 } +00254 } +00255 <font class="keywordflow">else</font> +00256 { +00257 <font class="comment">// Retrieve received message loaded by dataAvailable()</font> +00258 buffer = _MR_Recorder.ReceivedMessages.front().Message; +00259 _MR_Recorder.ReceivedMessages.pop(); +00260 } +00261 <font class="preprocessor">#endif</font> +00262 <font class="preprocessor"></font> +00263 buffer.readType (); +00264 } +00265 +00266 <font class="comment">/*</font> +00267 <font class="comment"> *</font> +00268 <font class="comment"> */</font> +<a name="l00269"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#a9">00269</a> <a class="code" href="namespaceNLNET.html#a0">TSockId</a> CCallbackClient::getSockId (<a class="code" href="namespaceNLNET.html#a0">TSockId</a> hostid) +00270 { +00271 <a class="code" href="debug_8h.html#a6">nlassert</a> (hostid == InvalidSockId); +00272 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00273 +00274 <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CBufClient.html#a18">id</a> (); +00275 } +00276 +00277 +00278 <font class="comment">/*</font> +00279 <font class="comment"> * Connect to the specified host</font> +00280 <font class="comment"> * Recorded : YES</font> +00281 <font class="comment"> * Replayed : YES</font> +00282 <font class="comment"> */</font> +<a name="l00283"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#a4">00283</a> <font class="keywordtype">void</font> CCallbackClient::connect( <font class="keyword">const</font> CInetAddress& <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a> ) +00284 { +00285 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00286 +00287 <a class="code" href="classNLNET_1_1CCallbackClient.html#o0">SendNextValue</a> = <a class="code" href="classNLNET_1_1CCallbackClient.html#o1">ReceiveNextValue</a> = 0; +00288 +00289 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00290 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState != <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s2">Replay</a> ) +00291 { +00292 <font class="keywordflow">try</font> +00293 { +00294 <font class="preprocessor">#endif</font> +00295 <font class="preprocessor"></font> +00296 <font class="comment">// Connect</font> +00297 CBufClient::connect( <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a> ); +00298 +00299 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00300 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState == <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s1">Record</a> ) +00301 { +00302 <font class="comment">// Record connection</font> +00303 CMessage addrmsg; +00304 addrmsg.serial( const_cast<CInetAddress&>(<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>) ); +00305 _MR_Recorder.recordNext( _MR_UpdateCounter, <a class="code" href="namespaceNLNET.html#a156a14">Connecting</a>, <a class="code" href="classNLNET_1_1CBufClient.html#n0">_BufSock</a>, addrmsg ); +00306 } +00307 } +00308 <font class="keywordflow">catch</font> ( ESocketConnectionFailed& ) +00309 { +00310 <font class="keywordflow">if</font> ( _MR_RecordingState == <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s1">Record</a> ) +00311 { +00312 <font class="comment">// Record connection</font> +00313 CMessage addrmsg; +00314 addrmsg.serial( const_cast<CInetAddress&>(<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>) ); +00315 _MR_Recorder.recordNext( _MR_UpdateCounter, <a class="code" href="namespaceNLNET.html#a156a15">ConnFailing</a>, <a class="code" href="classNLNET_1_1CBufClient.html#n0">_BufSock</a>, addrmsg ); +00316 } +00317 <font class="keywordflow">throw</font>; +00318 } +00319 } +00320 <font class="keywordflow">else</font> +00321 { +00322 <font class="comment">// Check the connection : failure or not</font> +00323 <a class="code" href="namespaceNLNET.html#a156">TNetworkEvent</a> event = _MR_Recorder.replayConnectionAttempt( <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a> ); +00324 <font class="keywordflow">switch</font> ( event ) +00325 { +00326 <font class="keywordflow">case</font> <a class="code" href="namespaceNLNET.html#a156a14">Connecting</a> : +00327 <font class="comment">// Set the remote address</font> +00328 <a class="code" href="debug_8h.html#a6">nlassert</a>( ! <a class="code" href="classNLNET_1_1CBufClient.html#n0">_BufSock</a>->Sock->connected() ); +00329 <a class="code" href="classNLNET_1_1CBufClient.html#n0">_BufSock</a>->connect( <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>, <a class="code" href="classNLNET_1_1CBufClient.html#n1">_NoDelay</a>, <font class="keyword">true</font> ); +00330 <a class="code" href="classNLNET_1_1CBufClient.html#n2">_PrevBytesDownloaded</a> = 0; +00331 <a class="code" href="classNLNET_1_1CBufClient.html#n3">_PrevBytesUploaded</a> = 0; +00332 <font class="comment">/*_PrevBytesReceived = 0;</font> +00333 <font class="comment"> _PrevBytesSent = 0;*/</font> +00334 <font class="keywordflow">break</font>; +00335 <font class="keywordflow">case</font> <a class="code" href="namespaceNLNET.html#a156a15">ConnFailing</a> : +00336 <font class="keywordflow">throw</font> ESocketConnectionFailed( <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a> ); +00337 <font class="comment">//break;</font> +00338 <font class="keywordflow">default</font> : +00339 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"LNETL3C: No connection event in replay data, at update #%"</font>NL_I64<font class="stringliteral">"u"</font>, _MR_UpdateCounter ); +00340 } +00341 } +00342 <font class="preprocessor">#endif</font> +00343 <font class="preprocessor"></font>} +00344 +00345 +00346 <font class="comment">/*</font> +00347 <font class="comment"> * Disconnect a connection</font> +00348 <font class="comment"> * Recorded : YES</font> +00349 <font class="comment"> * Replayed : YES</font> +00350 <font class="comment"> */</font> +<a name="l00351"></a><a class="code" href="classNLNET_1_1CCallbackClient.html#a7">00351</a> <font class="keywordtype">void</font> CCallbackClient::disconnect( <a class="code" href="namespaceNLNET.html#a0">TSockId</a> hostid ) +00352 { +00353 <a class="code" href="debug_8h.html#a6">nlassert</a> (hostid == InvalidSockId); <font class="comment">// should always be InvalidSockId on client</font> +00354 <a class="code" href="classNLNET_1_1CCallbackNetBase.html#b4">checkThreadId</a> (); +00355 +00356 <a class="code" href="classNLNET_1_1CCallbackClient.html#o0">SendNextValue</a> = <a class="code" href="classNLNET_1_1CCallbackClient.html#o1">ReceiveNextValue</a> = 0; +00357 +00358 <font class="comment">// Disconnect only if connected (same as physically connected for the client)</font> +00359 <font class="keywordflow">if</font> ( <a class="code" href="classNLNET_1_1CBufClient.html#n0">_BufSock</a>->connectedState() ) +00360 { +00361 +00362 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00363 <font class="preprocessor"></font> <font class="keywordflow">if</font> ( _MR_RecordingState != <a class="code" href="classNLNET_1_1CCallbackNetBase.html#s3s2">Replay</a> ) +00364 { +00365 <font class="preprocessor">#endif</font> +00366 <font class="preprocessor"></font> +00367 <font class="comment">// Disconnect</font> +00368 CBufClient::disconnect (); +00369 +00370 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00371 <font class="preprocessor"></font> } +00372 <font class="keywordflow">else</font> +00373 { +00374 <font class="comment">// Read (skip) disconnection in the file</font> +00375 <font class="keywordflow">if</font> ( ! (_MR_Recorder.checkNextOne( _MR_UpdateCounter ) == <a class="code" href="namespaceNLNET.html#a156a17">Disconnecting</a>) ) +00376 { +00377 <a class="code" href="debug_8h.html#a2">nlwarning</a>( <font class="stringliteral">"LNETL3C: No disconnection event in the replay data, at update #%"</font>NL_I64<font class="stringliteral">"u"</font>, _MR_UpdateCounter ); +00378 } +00379 } +00380 <font class="comment">// Record or replay disconnection (because disconnect() in the client does not push a disc. event)</font> +00381 noticeDisconnection( <a class="code" href="classNLNET_1_1CBufClient.html#n0">_BufSock</a> ); +00382 <font class="preprocessor">#endif</font> +00383 <font class="preprocessor"></font> } +00384 } +00385 +00386 +00387 <font class="preprocessor">#ifdef USE_MESSAGE_RECORDER</font> +00388 <font class="preprocessor"></font> +00389 +00390 <font class="comment">/*</font> +00391 <font class="comment"> * replay connection and disconnection callbacks, client version</font> +00392 <font class="comment"> */</font> +00393 <font class="keywordtype">bool</font> CCallbackClient::replaySystemCallbacks() +00394 { +00395 <font class="keywordflow">do</font> +00396 { +00397 <font class="keywordflow">if</font> ( _MR_Recorder.ReceivedMessages.empty() ) +00398 { +00399 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00400 } +00401 <font class="keywordflow">else</font> +00402 { +00403 <font class="keywordflow">switch</font>( _MR_Recorder.ReceivedMessages.front().Event ) +00404 { +00405 <font class="keywordflow">case</font> <a class="code" href="namespaceNLNET.html#a156a13">Receiving</a>: +00406 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00407 +00408 <font class="keywordflow">case</font> <a class="code" href="namespaceNLNET.html#a156a17">Disconnecting</a>: +00409 <a class="code" href="debug_8h.html#a0">nldebug</a>( <font class="stringliteral">"Disconnection event"</font> ); +00410 <a class="code" href="classNLNET_1_1CBufClient.html#n0">_BufSock</a>->setConnectedState( <font class="keyword">false</font> ); +00411 +00412 <font class="comment">// Call callback if needed</font> +00413 <font class="keywordflow">if</font> ( <a class="code" href="classNLNET_1_1CBufNetBase.html#b2">disconnectionCallback</a>() != NULL ) +00414 { +00415 <a class="code" href="classNLNET_1_1CBufNetBase.html#b2">disconnectionCallback</a>()( <a class="code" href="classNLNET_1_1CBufClient.html#a18">id</a>(), <a class="code" href="classNLNET_1_1CBufNetBase.html#b3">argOfDisconnectionCallback</a>() ); +00416 } +00417 <font class="keywordflow">break</font>; +00418 +00419 <font class="keywordflow">default</font>: +00420 <a class="code" href="debug_8h.html#a3">nlerror</a>( <font class="stringliteral">"LNETL1: Invalid system event type in client receive queue"</font> ); +00421 } +00422 <font class="comment">// Extract system event</font> +00423 _MR_Recorder.ReceivedMessages.pop(); +00424 } +00425 } +00426 <font class="keywordflow">while</font> ( true ); +00427 } +00428 +00429 +00430 <font class="preprocessor">#endif // USE_MESSAGE_RECORDER</font> +00431 <font class="preprocessor"></font> +00432 +00433 } <font class="comment">// NLNET</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </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> |