aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/nel/src/net/callback_net_base.cpp?rev=1.33&content-type=text/x-cvsweb-markup&sortby=date/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'cvs/cvsweb.cgi/code/nel/src/net/callback_net_base.cpp?rev=1.33&content-type=text/x-cvsweb-markup&sortby=date/index.html')
-rw-r--r--cvs/cvsweb.cgi/code/nel/src/net/callback_net_base.cpp?rev=1.33&content-type=text/x-cvsweb-markup&sortby=date/index.html556
1 files changed, 556 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/nel/src/net/callback_net_base.cpp?rev=1.33&content-type=text/x-cvsweb-markup&sortby=date/index.html b/cvs/cvsweb.cgi/code/nel/src/net/callback_net_base.cpp?rev=1.33&content-type=text/x-cvsweb-markup&sortby=date/index.html
new file mode 100644
index 00000000..b3f66b6e
--- /dev/null
+++ b/cvs/cvsweb.cgi/code/nel/src/net/callback_net_base.cpp?rev=1.33&content-type=text/x-cvsweb-markup&sortby=date/index.html
@@ -0,0 +1,556 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
+<HEAD><style> A { color:black }</style>
+<!-- hennerik CVSweb $Revision: 1.93 $ -->
+<TITLE>code/nel/src/net/callback_net_base.cpp - view - 1.33</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="callback_net_base.cpp?sortby=date"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="callback_net_base.cpp?sortby=date">callback_net_base.cpp</A>
+ CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/?sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=date">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/?sortby=date">src</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/?sortby=date">net</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/?sortby=date">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=date">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=date">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/?sortby=date">src</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/?sortby=date">net</a> / <a href="/cvs/cvsweb.cgi/code/nel/src/net/callback_net_base.cpp?sortby=date">callback_net_base.cpp</a>&nbsp;(<A HREF="/cvs/cvsweb.cgi/~checkout~/code/nel/src/net/callback_net_base.cpp?rev=1.33&amp;sortby=date" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nel/src/net/callback_net_base.cpp?rev=1.33','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
+Revision <B>1.33</B>, <i>Wed Jun 12 10:16:34 2002 UTC</i> (6 weeks, 4 days ago) by <i>lecroart</i>
+<BR>Branch: <b>MAIN</b>
+<BR>CVS Tags: <b>HEAD</b><BR>Changes since <b>1.32: +4 -7
+ lines</b><PRE>
+ADDED: changed NULL into InvalidSockId
+</PRE>
+</td></tr></table><HR noshade><PRE>/** \file callback_net_base.cpp
+ * Network engine, layer 3, base
+ *
+ * $Id: callback_net_base.cpp,v 1.33 2002/06/12 10:16:34 lecroart Exp $
+ */
+
+/* Copyright, 2001 Nevrax Ltd.
+ *
+ * This file is part of NEVRAX NEL.
+ * NEVRAX NEL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+
+ * NEVRAX NEL is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with NEVRAX NEL; see the file COPYING. If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include &quot;stdnet.h&quot;
+
+#include &quot;nel/misc/string_id_array.h&quot;
+#include &quot;nel/misc/hierarchical_timer.h&quot;
+
+#include &quot;nel/net/buf_sock.h&quot;
+#include &quot;nel/net/callback_net_base.h&quot;
+
+#ifdef USE_MESSAGE_RECORDER
+#pragma message ( &quot;NeL Net layer 3: message recorder enabled&quot; )
+#include &quot;nel/net/message_recorder.h&quot;
+#else
+#pragma message ( &quot;NeL Net layer 3: message recorder disabled&quot; )
+#endif
+
+
+using namespace std;
+using namespace NLMISC;
+
+namespace NLNET {
+
+
+/*
+ *
+ */
+void cbnbMessageRecvAssociations (CMessage &amp;msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// receive a new message association
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CStringIdArray::TStringId size;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (size);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: The other side gave me %d association strings&quot;, size);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (CStringIdArray::TStringId i = 0; i &lt; size; i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::string name;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CStringIdArray::TStringId id;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (id);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// if id == -1, it means that there are no callback associated to this message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// it should not happen, it mean that one side send a message that the other side
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// can't manage in his callbackarray.
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// to resolve the problem, add the callback in the callbackarray in the other side
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// and put NULL if you don't want to manage this message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert (id != -1);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: &nbsp;association '%s' -&gt; %d&quot;, name.c_str (), id);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;netbase.getSIDA().addString (name, id);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+
+/*
+ * the other side want to know some of my association, send them!
+ */
+void cbnbMessageAskAssociations (CMessage &amp;msgin, TSockId from, CCallbackNetBase &amp;netbase)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (netbase.getSIDA(), &quot;RA&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp;CStringIdArray::TStringId size;
+ &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (size);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: The other side want %d string associations&quot;, size);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (size);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (sint i = 0; i &lt; size; i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string name;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgin.serial (name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: &nbsp;sending association '%s' -&gt; %d&quot;, name.c_str (), netbase._OutputSIDA.getId(name));
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// if this assert occurs, it means that the other side ask an unknown message
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// or that there are different types of client (with differents callbackarray) and one of the client doesn't have this callback
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlassert(netbase._OutputSIDA.getId(name) != -1);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (name);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CStringIdArray::TStringId id = netbase._OutputSIDA.getId (name);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (id);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;// send the message to the other side
+ &nbsp; &nbsp; &nbsp; &nbsp;netbase.send (msgout, from);
+}
+
+static TCallbackItem cbnbMessageAssociationArray[] =
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;AA&quot;, cbnbMessageAskAssociations },
+ &nbsp; &nbsp; &nbsp; &nbsp;{ &quot;RA&quot;, cbnbMessageRecvAssociations },
+};
+
+
+/*
+ * Disconnection callback
+ */
+void cbnbNewDisconnection (TSockId from, void *data)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (data != NULL);
+ &nbsp; &nbsp; &nbsp; &nbsp;CCallbackNetBase *base = (CCallbackNetBase *)data;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug(&quot;LNETL3NB: cbnbNewDisconnection()&quot;);
+
+#ifdef USE_MESSAGE_RECORDER
+ &nbsp; &nbsp; &nbsp; &nbsp;// Record or replay disconnection
+ &nbsp; &nbsp; &nbsp; &nbsp;base-&gt;noticeDisconnection( from );
+#endif
+ &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;// Call the client callback if necessary
+ &nbsp; &nbsp; &nbsp; &nbsp;if (base-&gt;_DisconnectionCallback != NULL)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;base-&gt;_DisconnectionCallback (from, base-&gt;_DisconnectionCbArg);
+}
+
+
+/*
+ * Constructor
+ */
+CCallbackNetBase::CCallbackNetBase( &nbsp;TRecordingState rec, const string&amp; recfilename, bool recordall ) :
+ &nbsp; &nbsp; &nbsp; &nbsp;_FirstUpdate (true), _DisconnectionCallback(NULL), _DisconnectionCbArg(NULL)
+#ifdef USE_MESSAGE_RECORDER
+ &nbsp; &nbsp; &nbsp; &nbsp;, _MR_RecordingState(rec), _MR_UpdateCounter(0)
+#endif
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;_ThreadId = getThreadId ();
+ &nbsp; &nbsp; &nbsp; &nbsp;_NewDisconnectionCallback = cbnbNewDisconnection;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_BytesSent = 0;
+ &nbsp; &nbsp; &nbsp; &nbsp;_BytesReceived = 0;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;createDebug(); // for addNegativeFilter to work even in release and releasedebug modes
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// add the callback needed to associate messages with id
+ &nbsp; &nbsp; &nbsp; &nbsp;addCallbackArray (cbnbMessageAssociationArray, sizeof (cbnbMessageAssociationArray) / sizeof (cbnbMessageAssociationArray[0]));
+
+#ifdef USE_MESSAGE_RECORDER
+ &nbsp; &nbsp; &nbsp; &nbsp;switch ( _MR_RecordingState )
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp;case Record :
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_MR_Recorder.startRecord( recfilename, recordall );
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+ &nbsp; &nbsp; &nbsp; &nbsp;case Replay :
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_MR_Recorder.startReplay( recfilename );
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+ &nbsp; &nbsp; &nbsp; &nbsp;default:;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// No recording
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+#endif
+}
+
+
+/*
+ * &nbsp; &nbsp; &nbsp;Append callback array with the specified array
+ */
+void CCallbackNetBase::addCallbackArray (const TCallbackItem *callbackarray, CStringIdArray::TStringId arraysize)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;checkThreadId ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// be sure that the 2 array have the same size
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (_CallbackArray.size () == (uint)_OutputSIDA.size ());
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (arraysize == 1 &amp;&amp; callbackarray[0].Callback == NULL &amp;&amp; string(&quot;&quot;) == callbackarray[0].Key)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// it's an empty array, ignore it
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// resize the array
+ &nbsp; &nbsp; &nbsp; &nbsp;sint oldsize = _CallbackArray.size();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_CallbackArray.resize (oldsize + arraysize);
+ &nbsp; &nbsp; &nbsp; &nbsp;_OutputSIDA.resize (oldsize + arraysize);
+
+//TOO MUCH MESSAGE &nbsp; &nbsp; &nbsp;nldebug (&quot;L3NB_CB: Adding %d callback to the array&quot;, arraysize);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (sint i = 0; i &lt; arraysize; i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CStringIdArray::TStringId ni = oldsize + i;
+//TOO MUCH MESSAGE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;L3NB_CB: Adding callback to message '%s', id '%d'&quot;, callbackarray[i].Key, ni);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// copy callback value
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_CallbackArray[ni] = callbackarray[i];
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// add the string to the string id array
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_OutputSIDA.addString (callbackarray[i].Key, ni);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+// &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_CB: Added %d callback Now, there's %d callback associated with message type&quot;, arraysize, _CallbackArray.size ());
+}
+
+
+/*
+ * processOneMessage()
+ */
+void CCallbackNetBase::processOneMessage ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;checkThreadId ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;H_AUTO (CCallbackNetBase_processOneMessage);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgin (_OutputSIDA, &quot;&quot;, true);
+ &nbsp; &nbsp; &nbsp; &nbsp;TSockId tsid;
+ &nbsp; &nbsp; &nbsp; &nbsp;receive (msgin, &amp;tsid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_BytesReceived += msgin.length ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB: Received a message %s from %s&quot;, msgin.toString().c_str(), tsid-&gt;asString().c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;// now, we have to call the good callback
+ &nbsp; &nbsp; &nbsp; &nbsp;NLMISC::CStringIdArray::TStringId pos = -1;
+ &nbsp; &nbsp; &nbsp; &nbsp;if (msgin.TypeHasAnId)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pos = msgin.getId ();
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::string name = msgin.getName ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sint16 i;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (i = 0; i &lt; (sint16) _CallbackArray.size (); i++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (name == _CallbackArray[i].Key)
+ &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;pos = i;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+ &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;TMsgCallback &nbsp; &nbsp; &nbsp; &nbsp;cb = NULL;
+ &nbsp; &nbsp; &nbsp; &nbsp;if (pos &lt; 0 || pos &gt;= (sint16) _CallbackArray.size ())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (_DefaultCallback == NULL)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;LNETL3NB_CB: Callback %s not found in _CallbackArray&quot;, msgin.toString().c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cb = _DefaultCallback;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cb = _CallbackArray[pos].Callback;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;TSockId realid = getSockId (tsid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if (!realid-&gt;AuthorizedCallback.empty() &amp;&amp; msgin.getName() != realid-&gt;AuthorizedCallback)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;LNETL3NB_CB: %s try to call the callback %s but only %s is authorized. Disconnect him!&quot;, tsid-&gt;asString().c_str(), msgin.toString().c_str(), tsid-&gt;AuthorizedCallback.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;disconnect (tsid);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else if (cb == NULL)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;LNETL3NB_CB: Callback %s is NULL, can't call it&quot;, msgin.toString().c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_CB: Calling callback (%s)%s&quot;, msgin.getName().c_str(), (cb==_DefaultCallback)?&quot; DEFAULT_CB&quot;:&quot;&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cb(msgin, realid, *this);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;
+/*
+ &nbsp; &nbsp; &nbsp; &nbsp;if (pos &lt; 0 || pos &gt;= (sint16) _CallbackArray.size ())
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (_DefaultCallback == NULL)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;LNETL3NB_CB: Callback %s not found in _CallbackArray&quot;, msgin.toString().c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &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;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TSockId realid = getSockId (tsid);
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!realid-&gt;AuthorizedCallback.empty() &amp;&amp; msgin.getName() != realid-&gt;AuthorizedCallback)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;LNETL3NB_CB: %s try to call the callback %s but only %s is authorized. Disconnect him!&quot;, tsid-&gt;asString().c_str(), msgin.toString().c_str(), tsid-&gt;AuthorizedCallback.c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;disconnect (tsid);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if (_CallbackArray[pos].Callback == NULL)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlwarning (&quot;LNETL3NB_CB: Callback %s is NULL, can't call it&quot;, msgin.toString().c_str());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_CB: Calling callback (%s)&quot;, _CallbackArray[pos].Key);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_CallbackArray[pos].Callback (msgin, realid, *this);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+*/
+}
+
+
+
+/*
+ * baseUpdate
+ * Recorded : YES
+ * Replayed : YES
+ */
+void CCallbackNetBase::baseUpdate (sint32 timeout)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;checkThreadId ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;H_AUTO (CCallbackNetBase_baseUpdate);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert( timeout &gt;= -1 );
+ &nbsp; &nbsp; &nbsp; &nbsp;TTime t0 = CTime::getLocalTime();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;// The first time, we init time counters
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;if (_FirstUpdate)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug(&quot;LNETL3NB: First update()&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_FirstUpdate = false;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_LastUpdateTime = t0;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_LastMovedStringArray = t0;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;// Every 1 seconds if we have new unknown association, we ask them to the other side
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;if (t0 - _LastUpdateTime &gt; &nbsp;1000)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug(&quot;LNETL3NB: baseUpdate()&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_LastUpdateTime = t0;
+
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const set&lt;string&gt; &amp;sa = _InputSIDA.getNeedToAskedStringArray ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!sa.empty ())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (_InputSIDA, &quot;AA&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//nlassert (sa.size () &lt; 65536); // no size limit anymore
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CStringIdArray::TStringId size = sa.size ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: I need %d string association, ask them to the other side&quot;, size);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (size);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (set&lt;string&gt;::iterator it = sa.begin(); it != sa.end(); it++)
+ &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;nldebug (&quot;LNETL3NB_ASSOC: &nbsp;what is the id of '%s'?&quot;, (*it).c_str ());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string str(*it);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (str);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// send the message to the other side
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;send (msgout, 0);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_InputSIDA.moveNeedToAskToAskedStringArray();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_LastMovedStringArray = t0;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;// Every 60 seconds if we have not answered association, we ask again to get them!
+ &nbsp; &nbsp; &nbsp; &nbsp;//
+ &nbsp; &nbsp; &nbsp; &nbsp;if (!_InputSIDA.getAskedStringArray().empty() &amp;&amp; t0 - _LastMovedStringArray &gt; 60000)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// we didn't have an answer for the association, resend them
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const set&lt;string&gt; sa = _InputSIDA.getAskedStringArray ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CMessage msgout (_InputSIDA, &quot;AA&quot;);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//nlassert (sa.size () &lt; 65536); // no size limit anymore
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CStringIdArray::TStringId size = sa.size ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: client didn't answer my asked association, retry! I need %d string association, ask them to the other side&quot;, size);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (size);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (set&lt;string&gt;::iterator it = sa.begin(); it != sa.end(); it++)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: &nbsp;what is the id of '%s'?&quot;, (*it).c_str ());
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;string str(*it);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msgout.serial (str);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// sends the message to the other side
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;send (msgout, 0);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_LastMovedStringArray = t0;
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;/*
+ &nbsp; &nbsp; &nbsp; &nbsp; * timeout -1 &nbsp; &nbsp;=&gt; &nbsp;read one message in the queue
+ &nbsp; &nbsp; &nbsp; &nbsp; * timeout 0 &nbsp; &nbsp; =&gt; &nbsp;read all messages in the queue
+ &nbsp; &nbsp; &nbsp; &nbsp; * timeout other =&gt; &nbsp;read all messages in the queue until timeout expired (at least all one time)
+ &nbsp; &nbsp; &nbsp; &nbsp; */
+
+ &nbsp; &nbsp; &nbsp; &nbsp;bool exit = false;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;while (!exit)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// process all messages in the queue
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while (dataAvailable ())
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;processOneMessage ();
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (timeout == -1)
+ &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;exit = true;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;
+ &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;// need to exit?
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (timeout == 0 || (sint32)(CTime::getLocalTime() - t0) &gt; timeout)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit = true;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// enable multithreading on windows :-/
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;H_AUTO (CCallbackNetBase_baseUpdate_nlSleep);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlSleep (10);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+#ifdef USE_MESSAGE_RECORDER
+ &nbsp; &nbsp; &nbsp; &nbsp;_MR_UpdateCounter++;
+#endif
+
+}
+
+
+const &nbsp; CInetAddress&amp; CCallbackNetBase::hostAddress (TSockId hostid)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// should never be called
+ &nbsp; &nbsp; &nbsp; &nbsp;nlstop;
+ &nbsp; &nbsp; &nbsp; &nbsp;static CInetAddress tmp;
+ &nbsp; &nbsp; &nbsp; &nbsp;return tmp;
+}
+
+void &nbsp; &nbsp;CCallbackNetBase::setOtherSideAssociations (const char **associationarray, NLMISC::CStringIdArray::TStringId arraysize)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;checkThreadId ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: setOtherSideAssociations() sets %d association strings&quot;, arraysize);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;for (sint i = 0; i &lt; arraysize; i++)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB_ASSOC: &nbsp;association '%s' -&gt; %d&quot;, associationarray[i], i);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;getSIDA().addString (associationarray[i], i);
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+void &nbsp; &nbsp;CCallbackNetBase::displayAllMyAssociations ()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;checkThreadId ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;_OutputSIDA.display ();
+}
+
+void &nbsp; &nbsp;CCallbackNetBase::authorizeOnly (const char *callbackName, TSockId hostid)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;checkThreadId ();
+
+ &nbsp; &nbsp; &nbsp; &nbsp;nldebug (&quot;LNETL3NB: authorizeOnly (%s, %s)&quot;, callbackName, hostid-&gt;asString().c_str());
+
+ &nbsp; &nbsp; &nbsp; &nbsp;hostid = getSockId (hostid);
+ &nbsp; &nbsp; &nbsp; &nbsp;
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (hostid != InvalidSockId);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;hostid-&gt;AuthorizedCallback = (callbackName == NULL)?&quot;&quot;:callbackName;
+}
+
+
+#ifdef USE_MESSAGE_RECORDER
+
+/*
+ * Replay dataAvailable() in replay mode
+ */
+bool CCallbackNetBase::replayDataAvailable()
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert( _MR_RecordingState == Replay );
+
+ &nbsp; &nbsp; &nbsp; &nbsp;if ( _MR_Recorder.ReceivedMessages.empty() )
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Fill the queue of received messages related to the present update
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_MR_Recorder.replayNextDataAvailable( _MR_UpdateCounter );
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+
+ &nbsp; &nbsp; &nbsp; &nbsp;return replaySystemCallbacks();
+}
+
+
+/*
+ * Record or replay disconnection
+ */
+void CCallbackNetBase::noticeDisconnection( TSockId hostid )
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;nlassert (hostid != InvalidSockId); &nbsp; &nbsp; &nbsp; &nbsp;// invalid hostid
+ &nbsp; &nbsp; &nbsp; &nbsp;if ( _MR_RecordingState != Replay )
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( _MR_RecordingState == Record )
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Record disconnection
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CMessage emptymsg;
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_MR_Recorder.recordNext( _MR_UpdateCounter, Disconnecting, hostid, emptymsg );
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;else
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Replay disconnection
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hostid-&gt;disconnect( false );
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+}
+
+#endif // USE_MESSAGE_RECORDER
+
+
+
+/*
+ * checkThreadId
+ */
+void CCallbackNetBase::checkThreadId () const
+{
+/* &nbsp; &nbsp; &nbsp;some people use this class in different thread but with a mutex to be sure to have
+ &nbsp; &nbsp; &nbsp; &nbsp;no concurent access
+ &nbsp; &nbsp; &nbsp; &nbsp;if (getThreadId () != _ThreadId)
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nlerror (&quot;You try to access to the same CCallbackClient or CCallbackServer with 2 differents thread (%d and %d)&quot;, _ThreadId, getThreadId());
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+*/
+}
+
+
+} // NLNET
+
+</PRE> \ No newline at end of file