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
blob: b3f66b6e878cc7e8d2b77a0de2f24141f33941b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
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>