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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
|
<!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>unified_network.cpp</h1><a href="unified__network_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00007 <font class="comment">/* Copyright, 2002 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="unified__network_8h.html">nel/net/unified_network.h</a>"</font>
00029
00030 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
00031 <font class="keyword">using</font> <font class="keyword">namespace </font>NLMISC;
00032
00033
00034 <font class="keyword">namespace </font>NLNET {
00035
00036 CLog <a class="code" href="namespaceNLNET.html#a141">test</a>(CLog::LOG_INFO);
00037 CFileDisplayer <a class="code" href="namespaceNLNET.html#a60">fd</a>;
00038
00039 <font class="keyword">static</font> uint <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> = 0;
00040
00041 <font class="keyword">static</font> <font class="keyword">const</font> uint64 <a class="code" href="namespaceNLNET.html#a69">AppIdDeadConnection</a> = 0xDEAD;
00042
<a name="l00043"></a><a class="code" href="unified__network_8cpp.html#a0">00043</a> <font class="preprocessor">#define AUTOCHECK_DISPLAY nlwarning</font>
00044 <font class="preprocessor"></font><font class="comment">//#define AUTOCHECK_DISPLAY CUnifiedNetwork::getInstance()->displayInternalTables (), nlerror</font>
00045
00046 <font class="comment">// ace retirer ca</font>
00047 <font class="keyword">static</font> string <a class="code" href="namespaceNLNET.html#a70">allstuffs</a>;
00048
00049 <font class="comment">//</font>
00050 <font class="comment">// Callbacks from NAMING SERVICE</font>
00051 <font class="comment">//</font>
00052
00053 <font class="comment">// when a service registers</font>
00054 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a142">uNetRegistrationBroadcast</a>(<font class="keyword">const</font> string &name, <a class="code" href="namespaceNLNET.html#a19">TServiceId</a> sid, <font class="keyword">const</font> vector<CInetAddress> &<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>)
00055 {
00056 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"HNETL5: + naming %s-%hu '%s'"</font>, name.c_str(), (uint16)sid, <a class="code" href="namespaceNLNET.html#a82">vectorCInetAddressToString</a>(addr).c_str ());
00057
00058 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"+naming "</font>+name+<font class="stringliteral">"-"</font>+toString(sid)+<font class="stringliteral">"\n"</font>;
00059 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"+naming %s-%hu"</font>, name.c_str (), (uint16)sid);
00060
00061 CUnifiedNetwork *uni= CUnifiedNetwork::getInstance();
00062
00063 <font class="keywordflow">if</font> (uni->_SId == sid)
00064 {
00065 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"itsme!!!\n"</font>;
00066 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"itsme!!!"</font>);
00067 <font class="comment">// it's me! don't add me!!!</font>
00068 <font class="keywordflow">return</font>;
00069 }
00070
00071 <font class="comment">// add the unified connection</font>
00072
00073 <font class="keywordflow">if</font>(sid >= uni->_IdCnx.size ())
00074 uni->_IdCnx.resize (sid+1);
00075
00076 <font class="keywordflow">if</font> (uni->_IdCnx[sid].State == CUnifiedNetwork::CUnifiedConnection::NotUsed)
00077 {
00078 uni->_IdCnx[sid] = CUnifiedNetwork::CUnifiedConnection(name, sid, <font class="keyword">false</font>);
00079 uni->_UsedConnection.push_back (sid);
00080 }
00081
00082 <font class="keywordflow">if</font> (!uni->_IdCnx[sid].ExtAddress.empty ()) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: %s-%hu already inserted in the table with '%s'"</font>, name.c_str(), (uint16)sid, <a class="code" href="namespaceNLNET.html#a82">vectorCInetAddressToString</a> (uni->_IdCnx[sid].ExtAddress).c_str ());
00083
00084
00085 <font class="comment">// set the list of external addresses</font>
00086
00087 <a class="code" href="debug_8h.html#a6">nlassert</a> (!<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.empty());
00088
00089 uni->_IdCnx[sid].ExtAddress = <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>;
00090
00091 <font class="comment">// associate nid with ext address</font>
00092 uni->_IdCnx[sid].setupNetworkAssociation (uni->_NetworkAssociations, uni->_DefaultNetwork);
00093 }
00094
00095 <font class="comment">// when a service unregisters</font>
00096 <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a143">uNetUnregistrationBroadcast</a>(<font class="keyword">const</font> string &name, <a class="code" href="namespaceNLNET.html#a19">TServiceId</a> sid, <font class="keyword">const</font> vector<CInetAddress> &<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>)
00097 {
00098 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"HNETL5: - naming %s-%hu '%s'"</font>, name.c_str(), (uint16)sid, <a class="code" href="namespaceNLNET.html#a82">vectorCInetAddressToString</a> (addr).c_str ());
00099
00100 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"-naming "</font>+name+<font class="stringliteral">"-"</font>+toString(sid)+<font class="stringliteral">"\n"</font>;
00101 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"-naming %s-%hu"</font>, name.c_str (), (uint16)sid);
00102
00103 <font class="comment">// get the service connection</font>
00104 CUnifiedNetwork *uni = CUnifiedNetwork::getInstance();
00105
00106 CUnifiedNetwork::CUnifiedConnection *uc = uni->getUnifiedConnection (sid);
00107 <font class="keywordflow">if</font> (uc == 0) <font class="keywordflow">return</font>; <font class="comment">// should never happen, the getUnifiedConnection() will generate a AUTOCHECK_DISPLAY</font>
00108
00109 <font class="comment">// call the user callback</font>
00110 CUnifiedNetwork::TNameMappedCallback::iterator it2 = uni->_DownCallbacks.find(uc->ServiceName);
00111
00112 <font class="keywordflow">if</font> (it2 != uni->_DownCallbacks.end())
00113 {
00114 <font class="comment">// call it</font>
00115 <a class="code" href="namespaceNLNET.html#a25">TUnifiedNetCallback</a> cb = (*it2).second.first;
00116 cb(uc->ServiceName, uc->ServiceId, (*it2).second.second);
00117 }
00118
00119 <font class="keywordflow">for</font> (uint c = 0; c < uni->_DownUniCallback.size (); c++)
00120 {
00121 <font class="keywordflow">if</font> (uni->_DownUniCallback[c].first != NULL)
00122 uni->_DownUniCallback[c].first(uc->ServiceName, uc->ServiceId, uni->_DownUniCallback[c].second);
00123 }
00124
00125 <font class="keywordflow">if</font>(!uc->Connection.empty ())
00126 {
00127 <font class="comment">// set all connection to dead, now, all messages received on this socket will be ignored and closed</font>
00128 <font class="keywordflow">for</font> (uint i = 0; i < uc->Connection.size (); ++i)
00129 {
00130 <font class="keywordflow">if</font> (uc->Connection[i].valid())
00131 uc->Connection[i].setAppId (<a class="code" href="namespaceNLNET.html#a69">AppIdDeadConnection</a>);
00132 }
00133
00134 <font class="comment">//</font>
00135 <font class="comment">// It's the first connection that added the _NamedCnx so if there s no connection, no need to</font>
00136 <font class="comment">// remove entry in _NamedCnx</font>
00137 <font class="comment">//</font>
00138
00139 uni->removeNamedCnx (uc->ServiceName, uc->ServiceId);
00140 }
00141
00142 <font class="comment">// remove the _UsedConnection</font>
00143 <font class="keywordtype">bool</font> found = <font class="keyword">false</font>;
00144 <font class="keywordflow">for</font> (vector<uint16>::iterator it = uni->_UsedConnection.begin (); it != uni->_UsedConnection.end(); it++)
00145 {
00146 <font class="keywordflow">if</font> (*it == uc->ServiceId)
00147 {
00148 found = <font class="keyword">true</font>;
00149 uni->_UsedConnection.erase (it);
00150 <font class="keywordflow">break</font>;
00151 }
00152 }
00153 <font class="keywordflow">if</font> (!found) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: can't find the sid %hu in the _UsedConnection"</font>, uc->ServiceId);
00154
00155 <font class="comment">// reset the unified connection</font>
00156 uc->reset ();
00157 }
00158
00159
00160 <font class="comment">//</font>
00161 <font class="comment">// Callbacks from connection/disconnection services</font>
00162 <font class="comment">//</font>
00163
<a name="l00164"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a144">00164</a> <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a144">uncbConnection</a>(<a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, <font class="keywordtype">void</font> *arg)
00165 {
00166 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: + connec '%s'"</font>, from->asString().c_str());
00167
00168 from->setAppId (<a class="code" href="namespaceNLNET.html#a69">AppIdDeadConnection</a>);
00169 }
00170
<a name="l00171"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a145">00171</a> <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a145">uncbDisconnection</a>(<a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, <font class="keywordtype">void</font> *arg)
00172 {
00173 <font class="keywordflow">if</font>(from->appId () == <a class="code" href="namespaceNLNET.html#a69">AppIdDeadConnection</a>)
00174 {
00175 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: - connec '%s'"</font>, from->asString().c_str());
00176 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"-connect dead conenction"</font>);
00177 }
00178 <font class="keywordflow">else</font>
00179 {
00180 CUnifiedNetwork *uni = CUnifiedNetwork::getInstance();
00181 uint16 sid = (uint16)from->appId();
00182 CUnifiedNetwork::CUnifiedConnection *uc = uni->getUnifiedConnection (sid);
00183 <font class="keywordflow">if</font> (uc == 0)
00184 {
00185 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: - connec '%s' sid %hu"</font>, from->asString().c_str(), sid);
00186 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"-connect '%s' %hu"</font>, from->asString ().c_str (), sid);
00187 }
00188 <font class="keywordflow">else</font>
00189 {
00190 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: - connec '%s' %s-%hu"</font>, from->asString().c_str(), uc->ServiceName.c_str (), sid);
00191 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"-connect "</font>+uc->ServiceName+<font class="stringliteral">"-"</font>+toString(sid)+<font class="stringliteral">"\n"</font>;
00192 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"-connect %s-%hu"</font>, uc->ServiceName.c_str (), (uint16)(uc->ServiceId));
00193
00194 <font class="keywordflow">if</font> (uc->IsExternal)
00195 {
00196 <font class="keywordflow">if</font> (!uc->AutoRetry)
00197 {
00198 <font class="comment">// If it s a external service with no auto retry, remove the connection</font>
00199
00200 <font class="comment">// call the user callback</font>
00201 CUnifiedNetwork::TNameMappedCallback::iterator it2 = uni->_DownCallbacks.find(uc->ServiceName);
00202
00203 <font class="keywordflow">if</font> (it2 != uni->_DownCallbacks.end())
00204 {
00205 <font class="comment">// call it</font>
00206 <a class="code" href="namespaceNLNET.html#a25">TUnifiedNetCallback</a> cb = (*it2).second.first;
00207 cb(uc->ServiceName, uc->ServiceId, (*it2).second.second);
00208 }
00209
00210 <font class="keywordflow">for</font> (uint c = 0; c < uni->_DownUniCallback.size (); c++)
00211 {
00212 <font class="keywordflow">if</font> (uni->_DownUniCallback[c].first != NULL)
00213 uni->_DownUniCallback[c].first(uc->ServiceName, uc->ServiceId, uni->_DownUniCallback[c].second);
00214 }
00215
00216 uni->removeNamedCnx (uc->ServiceName, uc->ServiceId);
00217
00218 <font class="comment">// remove the _UsedConnection</font>
00219 <font class="keywordtype">bool</font> found = <font class="keyword">false</font>;
00220 <font class="keywordflow">for</font> (vector<uint16>::iterator it = uni->_UsedConnection.begin (); it != uni->_UsedConnection.end(); it++)
00221 {
00222 <font class="keywordflow">if</font> (*it == uc->ServiceId)
00223 {
00224 found = <font class="keyword">true</font>;
00225 uni->_UsedConnection.erase (it);
00226 <font class="keywordflow">break</font>;
00227 }
00228 }
00229 <font class="keywordflow">if</font> (!found) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: can't find the sid %hu in the _UsedConnection"</font>, uc->ServiceId);
00230
00231 uc->reset ();
00232 }
00233 }
00234 <font class="keywordflow">else</font>
00235 {
00236 <font class="comment">// reset the connection</font>
00237 uint i;
00238 <font class="keywordflow">for</font> (i = 0; i < uc->Connection.size (); i++)
00239 {
00240 <font class="keywordflow">if</font> (uc->Connection[i].valid() && uc->Connection[i].CbNetBase->getSockId(uc->Connection[i].HostId) == from)
00241 {
00242 <font class="keywordflow">if</font> (uc->Connection[i].IsServerConnection)
00243 {
00244 <font class="comment">// we have to remove the stuffs now because HostId will not be accessible later</font>
00245 uc->Connection[i].reset();
00246 }
00247 <font class="keywordflow">else</font>
00248 {
00249 <font class="comment">// if it s a client, we can't delete now because the callback client is currently in use</font>
00250 <font class="comment">// only disconnect</font>
00251 <font class="keywordflow">if</font>(uc->Connection[i].CbNetBase->connected ())
00252 {
00253 uc->Connection[i].CbNetBase->disconnect (uc->Connection[i].HostId);
00254 }
00255 }
00256 <font class="keywordflow">break</font>;
00257 }
00258 }
00259 <font class="keywordflow">if</font> (i == uc->Connection.size ())
00260 {
00261 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: received a disconnection from a service but the connection is not in my list!"</font>);
00262 }
00263 }
00264 }
00265
00266 from->setAppId (<a class="code" href="namespaceNLNET.html#a69">AppIdDeadConnection</a>);
00267 }
00268 }
00269
00270 <font class="comment">//</font>
00271 <font class="comment">// Callback from identication services</font>
00272 <font class="comment">//</font>
00273
<a name="l00274"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a146">00274</a> <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a146">uncbServiceIdentification</a>(CMessage &msgin, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, CCallbackNetBase &netbase)
00275 {
00276 string inSName;
00277 uint16 inSid;
00278
00279 <font class="keywordflow">if</font> (from->appId () != <a class="code" href="namespaceNLNET.html#a69">AppIdDeadConnection</a>)
00280 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: received a connec ident from an unknown connection 0x%"</font>NL_I64<font class="stringliteral">"X"</font>, from->appId ());
00281
00282 <font class="comment">// recover the service name and id</font>
00283 msgin.serial(inSName);
00284 msgin.serial(inSid);
00285 uint8 pos;
00286 msgin.serial (pos);
00287 <font class="keywordtype">bool</font> isExternal;
00288 msgin.serial (isExternal);
00289
00290 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: + connec ident '%s' %s-%hu pos %hu ext %d"</font>, from->asString().c_str(), inSName.c_str(), inSid, (uint16)pos, (uint8)isExternal);
00291
00292 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"+rconnect "</font>+inSName+<font class="stringliteral">"-"</font>+toString(inSid)+<font class="stringliteral">" pos "</font>+toString((uint16)pos)+<font class="stringliteral">"\n"</font>;
00293 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"+rconnect %s-%hu pos %hu"</font>, inSName.c_str (), (uint16)inSid, (uint16)pos);
00294
00295 <font class="keywordflow">if</font>(isExternal)
00296 {
00297 <a class="code" href="debug_8h.html#a6">nlassert</a> (pos == 0);
00298 }
00299
00300 <font class="keywordflow">if</font> (inSid == 0)
00301 {
00302 <font class="keywordflow">if</font> (isExternal)
00303 {
00304 inSid = CUnifiedNetwork::getInstance ()->_ExtSId++;
00305 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Received a connection from a service with a SId 0, we give him the SId %d"</font>, inSid);
00306 }
00307 <font class="keywordflow">else</font>
00308 {
00309 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Received a connection from a service with a SId 0 and wasn't external, disconnecting it"</font>);
00310 netbase.disconnect();
00311 <font class="keywordflow">return</font>;
00312 }
00313 }
00314
00315 from->setAppId(inSid);
00316
00317 <font class="comment">// add a new connection to the list</font>
00318 CUnifiedNetwork *uni= CUnifiedNetwork::getInstance();
00319
00320 <font class="keywordflow">if</font>(inSid >= uni->_IdCnx.size ())
00321 {
00322 uni->_IdCnx.resize (inSid+1);
00323 }
00324
00325 <font class="keywordflow">switch</font>(uni->_IdCnx[inSid].State)
00326 {
00327 <font class="keywordflow">case</font> CUnifiedNetwork::CUnifiedConnection::NotUsed: <font class="comment">// add the new unified connection</font>
00328 uni->_IdCnx[inSid] = CUnifiedNetwork::CUnifiedConnection(inSName, inSid, isExternal);
00329 uni->_UsedConnection.push_back (inSid);
00330 <font class="keywordflow">break</font>;
00331 <font class="keywordflow">default</font>:
00332 <font class="keywordflow">break</font>;
00333 }
00334
00335 <font class="keywordflow">if</font> (uni->_IdCnx[inSid].IsExternal != isExternal)
00336 {
00337 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: Receive a connection that is not totally external %d %d"</font>, uni->_IdCnx[inSid].IsExternal, isExternal);
00338 <font class="keywordflow">return</font>;
00339 }
00340
00341
00342 <font class="comment">// add the connection to the already inserted unified connection</font>
00343 <font class="keywordflow">if</font> (pos >= uni->_IdCnx[inSid].Connection.size ())
00344 uni->_IdCnx[inSid].Connection.resize(pos+1);
00345 uni->_IdCnx[inSid].Connection[pos] = CUnifiedNetwork::CUnifiedConnection::TConnection(&netbase, from);
00346
00347 <font class="comment">// If the connection is external, we'll never receive the ExtAddress by the naming service, so add it manually</font>
00348 <font class="keywordflow">if</font> (isExternal)
00349 {
00350 uni->_IdCnx[inSid].ExtAddress.push_back (netbase.hostAddress (from));
00351 uni->_IdCnx[inSid].setupNetworkAssociation (uni->_NetworkAssociations, uni->_DefaultNetwork);
00352 }
00353
00354
00355 <font class="comment">// todo ace temp to savoir comment c est possible ce cas la</font>
00356 <font class="keywordflow">if</font> (uni->_IdCnx[inSid].Connection.size() == 3)
00357 {
00358 CUnifiedNetwork::CUnifiedConnection *uc = &uni->_IdCnx[inSid];
00359 <a class="code" href="debug_8h.html#a12">nlstop</a>;
00360 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"ext addr %s"</font>, <a class="code" href="namespaceNLNET.html#a82">vectorCInetAddressToString</a> (uc->ExtAddress).c_str ());
00361 <font class="keywordflow">for</font>(uint i = 0; i < uc->Connection.size(); i++)
00362 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"cnx %s"</font>, uc->Connection[i].HostId->asString ().c_str ());
00363 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%s"</font>, <a class="code" href="namespaceNLNET.html#a70">allstuffs</a>.c_str ());
00364 }
00365
00366 <font class="comment">// send the callback to the user with the first connection</font>
00367 <font class="keywordflow">if</font> (uni->_IdCnx[inSid].Connection.size () == 1)
00368 {
00369 <font class="comment">// insert the name in the map to be able to send message with the name</font>
00370 uni->addNamedCnx (inSName, inSid);
00371
00372 <font class="comment">// now we warn the user</font>
00373 CUnifiedNetwork::TNameMappedCallback::iterator it = uni->_UpCallbacks.find(inSName);
00374 <font class="keywordflow">if</font> (it != uni->_UpCallbacks.end())
00375 {
00376 <font class="comment">// call it</font>
00377 <a class="code" href="namespaceNLNET.html#a25">TUnifiedNetCallback</a> cb = (*it).second.first;
00378 cb(inSName, inSid, (*it).second.second);
00379 }
00380
00381 <font class="keywordflow">for</font> (uint c = 0; c < uni->_UpUniCallback.size (); c++)
00382 {
00383 <font class="keywordflow">if</font> (uni->_UpUniCallback[c].first != NULL)
00384 uni->_UpUniCallback[c].first (inSName, inSid, uni->_UpUniCallback[c].second);
00385 }
00386 }
00387 }
00388
00389 <font class="comment">// the callbacks wrapper</font>
<a name="l00390"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a147">00390</a> <font class="keywordtype">void</font> <a class="code" href="namespaceNLNET.html#a147">uncbMsgProcessing</a>(CMessage &msgin, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> from, CCallbackNetBase &netbase)
00391 {
00392 <font class="keywordflow">if</font> (from->appId() == <a class="code" href="namespaceNLNET.html#a69">AppIdDeadConnection</a>)
00393 {
00394 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: Receive a message from a dead connection"</font>);
00395 <font class="keywordflow">return</font>;
00396 }
00397
00398 CUnifiedNetwork *uni = CUnifiedNetwork::getInstance();
00399 uint16 sid = (uint16)from->appId();
00400 CUnifiedNetwork::TMsgMappedCallback::iterator itcb;
00401
00402 itcb = uni->_Callbacks.find(msgin.getName());
00403 <font class="keywordflow">if</font> (itcb == uni->_Callbacks.end())
00404 {
00405 <font class="comment">// the callback doesn't exist</font>
00406 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't find callback '%s' called by service %hu"</font>, msgin.getName().c_str(), sid);
00407 }
00408 <font class="keywordflow">else</font>
00409 {
00410 CUnifiedNetwork::CUnifiedConnection *uc = uni->getUnifiedConnection (sid);
00411
00412 <font class="keywordflow">if</font> (uc == 0)
00413 {
00414 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Received a message from a service %hu that is not ready (bad appid? 0x%"</font>NL_I64<font class="stringliteral">"X)"</font>, sid, from->appId ());
00415 <font class="keywordflow">return</font>;
00416 }
00417 <font class="keywordflow">if</font>((*itcb).second == 0)
00418 {
00419 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Received message %s from a service %hu but the associated callback is NULL"</font>, msgin.getName ().c_str(), sid);
00420 <font class="keywordflow">return</font>;
00421 }
00422 (*itcb).second (msgin, uc->ServiceName, sid);
00423 }
00424 }
00425
00426
00427 TCallbackItem <a class="code" href="namespaceNLNET.html#a71">unServerCbArray</a>[] =
00428 {
00429 { <font class="stringliteral">"UN_SIDENT"</font>, <a class="code" href="namespaceNLNET.html#a146">uncbServiceIdentification</a> }
00430 };
00431
00432
00433 <font class="comment">//</font>
00434 <font class="comment">//</font>
00435 <font class="comment">//</font>
00436
00437 <font class="keywordtype">void</font> CUnifiedNetwork::init(<font class="keyword">const</font> CInetAddress *<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>, CCallbackNetBase::TRecordingState rec,
00438 <font class="keyword">const</font> string &shortName, uint16 port, <a class="code" href="namespaceNLNET.html#a19">TServiceId</a> &sid)
00439 {
00440 <font class="comment">//DebugLog->addNegativeFilter ("HNETL5");</font>
00441
00442 <font class="keywordflow">if</font> (_Initialised)
00443 {
00444 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: Unified network layer already initialized"</font>);
00445 <font class="keywordflow">return</font>;
00446 }
00447
00448 <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> = <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>();
00449
00450 vector<CInetAddress> laddr = CInetAddress::localAddresses();
00451
00452 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o9">_RecordingState</a> = rec;
00453 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a> = shortName;
00454 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a> = sid;
00455
00456 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a> != 0)
00457 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o16">_NamingServiceAddr</a> = *<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>;
00458
00459 <font class="comment">// if the address isn't 0, uses the naming service</font>
00460 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o16">_NamingServiceAddr</a>.<a class="code" href="classNLNET_1_1CInetAddress.html#a10">isValid</a> ())
00461 {
00462 <font class="comment">// connect the callback to know when a new service comes in or goes down</font>
00463 CNamingClient::setRegistrationBroadcastCallback(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#l5">uNetRegistrationBroadcast</a>);
00464 CNamingClient::setUnregistrationBroadcastCallback(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#l6">uNetUnregistrationBroadcast</a>);
00465
00466 <font class="comment">// connect to the naming service (may generate a ESocketConnectionFailed exception)</font>
00467 CNamingClient::connect(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o16">_NamingServiceAddr</a>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o9">_RecordingState</a>, laddr);
00468
00469 <font class="keywordflow">if</font> (port == 0)
00470 port = CNamingClient::queryServicePort ();
00471 }
00472
00473 <font class="comment">// setup the server callback only if server port != 0, otherwise there's no server callback</font>
00474 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o4">_ServerPort</a> = port;
00475
00476 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o4">_ServerPort</a> != 0)
00477 {
00478 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a> == 0);
00479 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a> = <font class="keyword">new</font> CCallbackServer;
00480 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->init(port);
00481 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->addCallbackArray(<a class="code" href="namespaceNLNET.html#a71">unServerCbArray</a>, 1); <font class="comment">// the service ident callback</font>
00482 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->setDefaultCallback(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a147">uncbMsgProcessing</a>); <font class="comment">// the default callback wrapper</font>
00483 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->setConnectionCallback(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a144">uncbConnection</a>, NULL);
00484 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->setDisconnectionCallback(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a145">uncbDisconnection</a>, NULL);
00485 }
00486 <font class="keywordflow">else</font>
00487 {
00488 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: ServerPort is 0 so I don't create a CCallbackServer"</font>);
00489 }
00490
00491 <font class="keywordflow">if</font> (CNamingClient::connected())
00492 {
00493 <font class="comment">// register the service</font>
00494 <font class="keywordflow">for</font> (uint i = 0; i < laddr.size(); i++)
00495 laddr[i].setPort(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o4">_ServerPort</a>);
00496
00497 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a> == 0)
00498 {
00499 CNamingClient::registerService(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>, laddr, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>);
00500 }
00501 <font class="keywordflow">else</font>
00502 {
00503 CNamingClient::registerServiceWithSId(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>, laddr, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>);
00504 }
00505
00506 sid = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>;
00507
00508 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: Server '%s' added, registered and listen to port %hu"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>.c_str (), <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o4">_ServerPort</a>);
00509 }
00510
00511 string fn = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>+<font class="stringliteral">"_"</font>+toString(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>)+<font class="stringliteral">".log"</font>;
00512 <a class="code" href="namespaceNLNET.html#a60">fd</a>.setParam (fn);
00513 <a class="code" href="namespaceNLNET.html#a141">test</a>.addDisplayer (&<a class="code" href="namespaceNLNET.html#a60">fd</a>);
00514 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"**************INIT***************"</font>);
00515
00516 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> = <font class="keyword">true</font>;
00517 }
00518
<a name="l00519"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a1">00519</a> <font class="keywordtype">void</font> CUnifiedNetwork::connect()
00520 {
00521 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::connect() whereas it is not initialised yet"</font>));
00522
00523 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
00524
00525
00526 <font class="keywordflow">if</font> (CNamingClient::connected())
00527 {
00528 <font class="comment">// get the services list</font>
00529 <font class="keyword">const</font> list<CNamingClient::CServiceEntry> &services = CNamingClient::getRegisteredServices();
00530
00531 <font class="comment">// connects to the registered services</font>
00532 list<CNamingClient::CServiceEntry>::const_iterator its;
00533
00534 <font class="comment">// don't connect to itself</font>
00535 <font class="keywordflow">for</font> (its = services.begin(); its != services.end(); ++its)
00536 {
00537 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a> != (*its).SId)
00538 {
00539 <font class="comment">// add service with name, address, ident, not external, service id, and not autoretry (obsolete)</font>
00540 <font class="comment">// we put the last true because the name callback should already inserted it by uNetRegistrationBroadcast()</font>
00541 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a3">addService</a>((*its).Name, (*its).Addr, <font class="keyword">true</font>, <font class="keyword">false</font>, (*its).SId, <font class="keyword">false</font>, <font class="keyword">true</font>);
00542 }
00543 <font class="keywordflow">else</font>
00544 {
00545 <font class="comment">// don't process services received after mine because they'll connect to me</font>
00546 <font class="keywordflow">break</font>;
00547 }
00548 }
00549 }
00550 }
00551
<a name="l00552"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a2">00552</a> <font class="keywordtype">void</font> CUnifiedNetwork::release()
00553 {
00554 <font class="keywordflow">if</font> (!<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a>)
00555 <font class="keywordflow">return</font>;
00556
00557 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
00558
00559 <font class="comment">// disconnect all clients</font>
00560 <font class="keywordflow">if</font>(_CbServer)
00561 {
00562 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->disconnect(InvalidSockId);
00563 <font class="keyword">delete</font> <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>;
00564 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a> = 0;
00565 }
00566
00567 <font class="comment">// disconnect all connections to servers</font>
00568 <font class="keywordflow">for</font> (uint i = 0; i<<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size(); ++i)
00569 {
00570 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State != CUnifiedNetwork::CUnifiedConnection::NotUsed)
00571 {
00572 <font class="keywordflow">for</font>(uint j = 0 ; j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size (); j++)
00573 {
00574 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].valid() && !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].IsServerConnection)
00575 {
00576 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].CbNetBase->connected ())
00577 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].CbNetBase->disconnect();
00578
00579 <font class="keyword">delete</font> <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].CbNetBase;
00580 }
00581 }
00582 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.clear ();
00583 }
00584 }
00585
00586 <font class="comment">// clear all other data</font>
00587 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.clear();
00588 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.clear ();
00589 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.clear();
00590 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.clear();
00591 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o7">_DownCallbacks</a>.clear();
00592 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o12">_Callbacks</a>.clear();
00593
00594 <font class="comment">// disconnect the connection with the naming service</font>
00595 <font class="keywordflow">if</font> (CNamingClient::connected ())
00596 CNamingClient::disconnect ();
00597 }
00598
00599 <font class="keywordtype">void</font> CUnifiedNetwork::addService(<font class="keyword">const</font> string &name, <font class="keyword">const</font> CInetAddress &<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>, <font class="keywordtype">bool</font> sendId, <font class="keywordtype">bool</font> external, uint16 sid, <font class="keywordtype">bool</font> autoRetry, <font class="keywordtype">bool</font> shouldBeAlreayInserted)
00600 {
00601 vector <CInetAddress> addrs;
00602 addrs.push_back (<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>);
00603 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a3">addService</a> (name, addrs, sendId, external, sid, autoRetry, shouldBeAlreayInserted);
00604 }
00605
00606 <font class="keywordtype">void</font> CUnifiedNetwork::addService(<font class="keyword">const</font> string &name, <font class="keyword">const</font> vector<CInetAddress> &<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>, <font class="keywordtype">bool</font> sendId, <font class="keywordtype">bool</font> external, uint16 sid, <font class="keywordtype">bool</font> autoRetry, <font class="keywordtype">bool</font> shouldBeAlreayInserted)
00607 {
00608 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::addService() whereas it is not initialised yet"</font>));
00609
00610 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
00611
00612 <font class="keywordflow">if</font> (external)
00613 sid = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o13">_ExtSId</a>++;
00614
00615 <a class="code" href="debug_8h.html#a1">nlinfo</a>(<font class="stringliteral">"HNETL5: addService %s-%hu '%s'"</font>, name.c_str(), sid, <a class="code" href="namespaceNLNET.html#a82">vectorCInetAddressToString</a>(addr).c_str());
00616
00617 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"addService "</font>+name+<font class="stringliteral">"-"</font>+toString(sid)+<font class="stringliteral">"\n"</font>;
00618 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"+service %s-%hu"</font>, name.c_str (), (uint16)sid);
00619
00620 <font class="keywordflow">if</font> (external && <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.size () != 1)
00621 {
00622 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: Can't add external service with more than one connection"</font>);
00623 }
00624
00625 <font class="comment">// add the entry in the unified connection table</font>
00626
00627 <font class="keywordflow">if</font> (sid >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size())
00628 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.resize(sid+1);
00629
00630 CUnifiedConnection *uc = &<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid];
00631
00632 <font class="comment">// at this point it s possible that the service already added in the _IdCnx by the uNetRegistrationBroadcast()</font>
00633
00634 <font class="keywordflow">if</font> (shouldBeAlreayInserted && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State == CUnifiedNetwork::CUnifiedConnection::NotUsed) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: the unified connection should already set by the naming reg broadcast and is not (%hu)"</font>, sid);
00635 <font class="keywordflow">if</font> (!shouldBeAlreayInserted && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State == CUnifiedNetwork::CUnifiedConnection::Ready) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: the unified connection should not already set but is (%hu)"</font>, sid);
00636
00637 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State == CUnifiedNetwork::CUnifiedConnection::NotUsed)
00638 {
00639 *uc = CUnifiedConnection(name, sid, external);
00640 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.push_back (sid);
00641 }
00642 <font class="keywordflow">else</font>
00643 {
00644 <font class="comment">// If the entry already set, check that all is correct</font>
00645 <font class="keywordflow">if</font> (name != uc->ServiceName) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: name are different in addService %s %s"</font>, name.c_str (), uc->ServiceName.c_str ());
00646 <font class="keywordflow">if</font> (sid != uc->ServiceId) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: sid are different in addService %hu %hu"</font>, sid, uc->ServiceId);
00647 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a> != uc->ExtAddress) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: external addr are different in addService '%s' '%s'"</font>, <a class="code" href="namespaceNLNET.html#a82">vectorCInetAddressToString</a>(addr).c_str(), <a class="code" href="namespaceNLNET.html#a82">vectorCInetAddressToString</a>(uc->ExtAddress).c_str ());
00648 }
00649 uc->AutoRetry = autoRetry;
00650 uc->SendId = sendId;
00651 uc->ExtAddress = <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>;
00652 <a class="code" href="debug_8h.html#a6">nlassert</a> (!<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.empty());
00653
00654 <font class="comment">// associate nid with ext address</font>
00655 uc->setupNetworkAssociation (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o19">_DefaultNetwork</a>);
00656
00657 <font class="comment">// connect to all connection</font>
00658 <font class="keywordtype">bool</font> connectSuccess;
00659
00660 <font class="keywordflow">if</font> (uc->Connection.size () < <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.size ())
00661 {
00662 uc->Connection.resize (<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.size ());
00663 }
00664
00665 vector<CInetAddress> laddr = CInetAddress::localAddresses();
00666
00667 <font class="keywordflow">for</font> (uint i = 0; i < <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.size(); i++)
00668 {
00669 <font class="comment">// first we have to look if we have a network that can established the connection</font>
00670
00671 uint j = 0;
00672 <font class="comment">// it s 127.0.0.1, it s ok</font>
00673 <font class="keywordflow">if</font> (!<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>[i].is127001 ())
00674 {
00675 <font class="keywordflow">for</font> (j = 0; j < laddr.size (); j++)
00676 {
00677 <font class="keywordflow">if</font> (laddr[j].internalNetAddress () == <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>[i].internalNetAddress ())
00678 {
00679 <font class="comment">// it's ok, we can try</font>
00680 <font class="keywordflow">break</font>;
00681 }
00682 }
00683
00684 <font class="comment">// If we don't found a valid network, we'll try with the first one.</font>
00685 <font class="comment">// It's happen, for example, when you try to connect to a service that is not in the network but use IP translation</font>
00686 <font class="keywordflow">if</font> (j == laddr.size ())
00687 {
00688 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"I can't access '%s' because I haven't a net card on this network, we'll use the first network"</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>[i].asString ().c_str ());
00689 j = 0;
00690 }
00691 }
00692
00693 <font class="comment">// create a new connection with the service, setup callback and connect</font>
00694 CCallbackClient *cbc = <font class="keyword">new</font> CCallbackClient();
00695 cbc->setDisconnectionCallback(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a145">uncbDisconnection</a>, NULL);
00696 cbc->setDefaultCallback(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a147">uncbMsgProcessing</a>);
00697 cbc->getSockId()->setAppId(sid);
00698
00699 <font class="keywordflow">try</font>
00700 {
00701 cbc->connect(<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>[i]);
00702 connectSuccess = <font class="keyword">true</font>;
00703
00704 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"+lconnect "</font>+name+<font class="stringliteral">"-"</font>+toString(sid)+<font class="stringliteral">"\n"</font>;
00705 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"+lconnect %s-%hu"</font>, name.c_str (), (uint16)sid);
00706 }
00707 <font class="keywordflow">catch</font> (ESocketConnectionFailed &e)
00708 {
00709 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: can't connect to %s (sid %u) now (%s) '%s'"</font>, name.c_str(), sid, e.what (), <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>[i].asString ().c_str());
00710 connectSuccess = <font class="keyword">false</font>;
00711
00712 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"+lconnect failed "</font>+name+<font class="stringliteral">"-"</font>+toString((uint16)sid)+<font class="stringliteral">"\n"</font>;
00713 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"+lconnect failed %s-%hu"</font>, name.c_str (), (uint16)sid);
00714 }
00715
00716 <font class="keywordflow">if</font> (!connectSuccess && !autoRetry)
00717 {
00718 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't add service because no retry and can't connect"</font>);
00719 <font class="keyword">delete</font> cbc;
00720 }
00721 <font class="keywordflow">else</font>
00722 {
00723 uc->Connection[i] = CUnifiedNetwork::CUnifiedConnection::TConnection(cbc);
00724
00725 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%s"</font>, <a class="code" href="namespaceNLNET.html#a70">allstuffs</a>.c_str ());
00726 }
00727
00728 <font class="keywordflow">if</font> (connectSuccess && sendId)
00729 {
00730 <font class="comment">// send identification to the service</font>
00731 CMessage msg(<font class="stringliteral">"UN_SIDENT"</font>);
00732 msg.serial(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>);
00733 uint16 ssid = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>;
00734 <font class="keywordflow">if</font> (uc->IsExternal)
00735 {
00736 <font class="comment">// in the case that the service is external, we can't send our sid because the external service can</font>
00737 <font class="comment">// have other connectin with the same sid (for example, LS can have 2 WS with same sid => sid = 0 and leave</font>
00738 <font class="comment">// the other side to find a good number</font>
00739 ssid = 0;
00740 }
00741 msg.serial(ssid); <font class="comment">// serializes a 16 bits service id</font>
00742 uint8 pos = j;
00743 msg.serial(pos); <font class="comment">// send the position in the connection table</font>
00744 msg.serial (uc->IsExternal);
00745 cbc->send (msg);
00746 }
00747 }
00748
00749 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.size () != uc->Connection.size())
00750 {
00751 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't connect to all connections to the service %d/%d"</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a414">addr</a>.size (), uc->Connection.size());
00752 }
00753
00754 <font class="keywordtype">bool</font> cntok = <font class="keyword">false</font>;
00755 <font class="keywordflow">for</font> (uint j = 0; j < uc->Connection.size(); j++)
00756 {
00757 <font class="keywordflow">if</font> (uc->Connection[j].CbNetBase != NULL)
00758 {
00759 <font class="keywordflow">if</font> (uc->Connection[j].CbNetBase->connected ())
00760 {
00761 cntok = <font class="keyword">true</font>;
00762 <font class="keywordflow">break</font>;
00763 }
00764 }
00765 }
00766
00767 <font class="keywordflow">if</font> (cntok)
00768 {
00769 <font class="comment">// add the name only if at least one connection is ok</font>
00770 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c5">addNamedCnx</a> (name, sid);
00771
00772 <font class="comment">// call the connection callback associated to this service</font>
00773 TNameMappedCallback::iterator itcb = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.find(name);
00774 <font class="keywordflow">if</font> (itcb != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.end() && (*itcb).second.first != NULL)
00775 {
00776 <a class="code" href="namespaceNLNET.html#a25">TUnifiedNetCallback</a> cb = (*itcb).second.first;
00777 cb(name, sid, (*itcb).second.second);
00778 }
00779
00780 <font class="keywordflow">if</font> (!external)
00781 {
00782 <font class="keywordflow">for</font> (uint i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>.size (); i++)
00783 {
00784 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>[i].first != NULL)
00785 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>[i].first (name, sid, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>[i].second);
00786 }
00787 }
00788 }
00789
00790 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"HNETL5: addService was successful"</font>);
00791 }
00792 <font class="comment">//</font>
00793 <font class="comment">//</font>
00794 <font class="comment">//</font>
00795
<a name="l00796"></a><a class="code" href="unified__network_8cpp.html#a1">00796</a> <font class="preprocessor">#define TIME_BLOCK(tick, instr) \</font>
00797 <font class="preprocessor">{ \</font>
00798 <font class="preprocessor"> TTicks _time_block_before = CTime::getPerformanceTime(); \</font>
00799 <font class="preprocessor"> instr ; \</font>
00800 <font class="preprocessor"> TTicks _time_block_after = CTime::getPerformanceTime(); \</font>
00801 <font class="preprocessor"> tick += (_time_block_after - _before); \</font>
00802 <font class="preprocessor">}</font>
00803 <font class="preprocessor"></font>
<a name="l00804"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a6">00804</a> <font class="keywordtype">void</font> CUnifiedNetwork::update(<a class="code" href="namespaceNLMISC.html#a183">TTime</a> timeout)
00805 {
00806 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::update() whereas it is not initialised yet"</font>));
00807
00808 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
00809
00810 <font class="keywordtype">bool</font> enableRetry; <font class="comment">// true every 5 seconds to reconnect if necessary</font>
00811
00812 <font class="comment">// Compute the real timeout based on the next update timeout</font>
00813 <a class="code" href="namespaceNLMISC.html#a183">TTime</a> t0 = CTime::getLocalTime ();
00814
00815 <font class="keywordflow">if</font> (timeout > 0)
00816 {
00817 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o15">_NextUpdateTime</a> == 0)
00818 {
00819 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o15">_NextUpdateTime</a> = t0 + timeout;
00820 }
00821 <font class="keywordflow">else</font>
00822 {
00823 <a class="code" href="namespaceNLMISC.html#a183">TTime</a> err = t0 - <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o15">_NextUpdateTime</a>;
00824 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o15">_NextUpdateTime</a> += timeout;
00825
00826 <font class="comment">// if we are too late, resync to the next value</font>
00827 <font class="keywordflow">while</font> (err > timeout)
00828 {
00829 err -= timeout;
00830 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o15">_NextUpdateTime</a> += timeout;
00831 }
00832
00833 timeout -= err;
00834 <font class="keywordflow">if</font> (timeout < 0) timeout = 0;
00835 }
00836 }
00837
00838 <font class="comment">// check if we need to retry to connect to the client</font>
00839 <font class="keywordflow">if</font> ((enableRetry = (t0-<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o14">_LastRetry</a> > 5000)))
00840 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o14">_LastRetry</a> = t0;
00841
00842 <font class="comment">// Try to reconnect to the naming service if connection lost</font>
00843 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o16">_NamingServiceAddr</a>.<a class="code" href="classNLNET_1_1CInetAddress.html#a10">isValid</a> ())
00844 {
00845 <font class="keywordflow">if</font> (CNamingClient::connected ())
00846 {
00847 CNamingClient::update ();
00848 }
00849 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (enableRetry)
00850 {
00851 <font class="keywordflow">try</font>
00852 {
00853 vector<CInetAddress> laddr = CInetAddress::localAddresses();
00854 CNamingClient::connect (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o16">_NamingServiceAddr</a>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o9">_RecordingState</a>, laddr);
00855 <font class="comment">// re-register the service</font>
00856 <font class="keywordflow">for</font> (uint i = 0; i < laddr.size(); i++)
00857 laddr[i].setPort(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o4">_ServerPort</a>);
00858 CNamingClient::resendRegisteration (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>, laddr, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>);
00859 }
00860 <font class="keywordflow">catch</font> (ESocketConnectionFailed &)
00861 {
00862 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Could not connect to the Naming Service (%s). Retrying in a few seconds..."</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o16">_NamingServiceAddr</a>.<a class="code" href="classNLNET_1_1CInetAddress.html#a17">asString</a>().c_str());
00863 }
00864 }
00865 }
00866
00867 <font class="keywordflow">while</font> (true)
00868 {
00869 <font class="comment">// update all server connections</font>
00870 <font class="keywordflow">if</font> (_CbServer)
00871 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->update(0);
00872
00873 <font class="comment">// update all client connections</font>
00874 <font class="keywordflow">for</font> (uint k = 0; k<<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.size(); ++k)
00875 {
00876 CUnifiedConnection &uc = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>[k]];
00877 <a class="code" href="debug_8h.html#a6">nlassert</a> (uc.State == CUnifiedNetwork::CUnifiedConnection::Ready);
00878 <font class="keywordflow">for</font> (uint j = 0; j < uc.Connection.size (); j++)
00879 {
00880 <font class="keywordflow">if</font> (!uc.Connection[j].valid())
00881 <font class="keywordflow">continue</font>;
00882
00883 <font class="keywordflow">if</font> (uc.Connection[j].IsServerConnection)
00884 <font class="keywordflow">continue</font>;
00885
00886 <font class="keywordflow">if</font> (uc.Connection[j].CbNetBase->connected ())
00887 {
00888 uc.Connection[j].CbNetBase->update(0);
00889 }
00890 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (enableRetry && uc.AutoRetry)
00891 {
00892 <font class="keywordflow">try</font>
00893 {
00894 CCallbackClient *cbc = (CCallbackClient *)uc.Connection[j].CbNetBase;
00895 cbc->connect(uc.ExtAddress[j]);
00896 uc.Connection[j].CbNetBase->getSockId()->setAppId(uc.ServiceId);
00897 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: reconnection to %s-%hu success"</font>, uc.ServiceName.c_str(), uc.ServiceId);
00898
00899
00900 <font class="comment">// add the name only if at least one connection is ok</font>
00901 <font class="keywordflow">if</font> (!<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c4">haveNamedCnx</a> (uc.ServiceName, uc.ServiceId))
00902 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c5">addNamedCnx</a> (uc.ServiceName, uc.ServiceId);
00903
00904 <font class="comment">// resend the identification is necessary</font>
00905 <font class="keywordflow">if</font> (uc.SendId)
00906 {
00907 <font class="comment">// send identification to the service</font>
00908 CMessage msg(<font class="stringliteral">"UN_SIDENT"</font>);
00909 msg.serial(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>);
00910
00911 uint16 ssid = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>;
00912 msg.serial(ssid); <font class="comment">// serializes a 16 bits service id</font>
00913 uint8 pos = j;
00914 msg.serial(pos); <font class="comment">// send the position in the connection table</font>
00915 msg.serial (uc.IsExternal);
00916 uc.Connection[j].CbNetBase->send (msg, uc.Connection[j].HostId);
00917 }
00918
00919 <font class="comment">// call the user callback</font>
00920 CUnifiedNetwork::TNameMappedCallback::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.find(uc.ServiceName);
00921 <font class="keywordflow">if</font> (it != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.end())
00922 {
00923 <font class="comment">// call it</font>
00924 <a class="code" href="namespaceNLNET.html#a25">TUnifiedNetCallback</a> cb = (*it).second.first;
00925 cb(uc.ServiceName, uc.ServiceId, (*it).second.second);
00926 }
00927
00928 <font class="keywordflow">for</font> (uint c = 0; c < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>.size (); c++)
00929 {
00930 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>[c].first != NULL)
00931 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>[c].first (uc.ServiceName, uc.ServiceId, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>[c].second);
00932 }
00933
00934 }
00935 <font class="keywordflow">catch</font> (ESocketConnectionFailed &e)
00936 {
00937 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: can't connect to %s-%hu now (%s)"</font>, uc.ServiceName.c_str(), uc.ServiceId, e.what ());
00938 }
00939 }
00940 }
00941 }
00942
00943 enableRetry = <font class="keyword">false</font>;
00944
00945 <font class="comment">// If it's the end, don't nlSleep()</font>
00946 <font class="keywordflow">if</font> (CTime::getLocalTime() - t0 > timeout)
00947 <font class="keywordflow">break</font>;
00948
00949 <font class="comment">// Enable windows multithreading before rescanning all connections</font>
00950 <a class="code" href="namespaceNLMISC.html#a236">nlSleep</a> (1);
00951 }
00952
00953 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c2">autoCheck</a>();
00954 }
00955
00956 <font class="comment">//</font>
00957 <font class="comment">//</font>
00958 <font class="comment">//</font>
<a name="l00959"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c7">00959</a> uint8 CUnifiedNetwork::findConnectionId (uint16 sid, uint8 nid)
00960 {
00961 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection.size () == 0)
00962 {
00963 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send message to %s because no connection are available"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ServiceName.c_str ());
00964 <font class="keywordflow">return</font> 0xFF;
00965 }
00966
00967 <font class="comment">// by default, connection id will be the default one</font>
00968 uint8 connectionId = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].DefaultNetwork;
00969
00970 <font class="keywordflow">if</font> (nid == 0xFF)
00971 {
00972 <font class="comment">// it s often appen because they didn't set a good network configuration, so it s in debug to disable it easily</font>
00973 <font class="comment">//nldebug ("HNETL5: nid %hu, will use the default connection %hu", (uint16)nid, (uint16)connectionId);</font>
00974 }
00975 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (nid >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].NetworkConnectionAssociations.size())
00976 {
00977 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: No net association for nid %hu, use the default connection %hu"</font>, (uint16)nid, (uint16)connectionId);
00978 }
00979 <font class="keywordflow">else</font>
00980 {
00981 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].NetworkConnectionAssociations[nid] >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection.size ())
00982 {
00983 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send message to %s because nid %d point on a bad connection (%d and only have %d cnx), use default connection"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ServiceName.c_str (), nid, connectionId, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection.size ());
00984 }
00985 <font class="keywordflow">else</font>
00986 {
00987 connectionId = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].NetworkConnectionAssociations[nid];
00988 }
00989 }
00990
00991 <font class="keywordflow">if</font> (connectionId >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection.size() || !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].valid() || !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].CbNetBase->connected())
00992 {
00993 <font class="comment">// there's a problem with the selected connectionID, so try to find a valid one</font>
00994 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't find selected connection id %hu to send message to %s because connection is not valid or connected, find a valid connection id"</font>, (uint16)connectionId, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ServiceName.c_str ());
00995
00996 <font class="keywordflow">for</font> (connectionId = 0; connectionId < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection.size(); connectionId++)
00997 {
00998 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].valid() && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].CbNetBase->connected())
00999 {
01000 <font class="comment">// we found one at last, use this one</font>
01001 <font class="comment">//nldebug ("HNETL5: Ok, we found a valid connectionid, use %hu", (uint16)connectionId);</font>
01002 <font class="keywordflow">break</font>;
01003 }
01004 }
01005
01006 <font class="keywordflow">if</font> (connectionId == <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection.size())
01007 {
01008 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send message to %s because default connection is not exist, valid or connected"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ServiceName.c_str ());
01009 <font class="keywordflow">return</font> 0xFF;
01010 }
01011 }
01012 <font class="keywordflow">return</font> connectionId;
01013 }
01014
01015
01016 <font class="comment">//</font>
01017 <font class="comment">//</font>
01018 <font class="comment">//</font>
01019
01020 <font class="keywordtype">bool</font> CUnifiedNetwork::send(<font class="keyword">const</font> string &serviceName, <font class="keyword">const</font> CMessage &msgout, uint8 nid)
01021 {
01022 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::send(const string&, const CMessage&) whereas it is not initialised yet"</font>));
01023
01024 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
01025
01026 TNameMappedConnection::const_iterator it;
01027 pair<TNameMappedConnection::const_iterator,TNameMappedConnection::const_iterator> <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>;
01028 <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a> = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.equal_range(serviceName);
01029
01030 <font class="keywordtype">bool</font> found = <font class="keyword">false</font>;
01031 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.end())
01032 {
01033 <font class="keywordflow">for</font> (it=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first; it!=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second; ++it)
01034 {
01035 uint16 sid = (*it).second;
01036 <font class="keywordflow">if</font> (sid >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size () || <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State != CUnifiedNetwork::CUnifiedConnection::Ready)
01037 {
01038 <font class="comment">// It often happen when the service is down (connection broke and the naming not already say that it s down)</font>
01039 <font class="comment">// In this case, just warn</font>
01040 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send to the service '%s' because it was in the _NamedCnx but not in _IdCnx (means that the service is down)"</font>, serviceName.c_str ());
01041 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01042 }
01043
01044 found = <font class="keyword">true</font>;
01045
01046 uint8 connectionId = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c7">findConnectionId</a> (sid, nid);
01047 <font class="keywordflow">if</font> (connectionId == 0xff) <font class="comment">// failed</font>
01048 {
01049 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send message to %hu because no connection available"</font>, sid);
01050 found = <font class="keyword">false</font>;
01051 <font class="keywordflow">continue</font>;
01052 }
01053
01054 <font class="comment">//nldebug ("HNETL5: send message to %s using nid %d cnx %d / %s", serviceName.c_str (), nid, connectionId, connectionId<_IdCnx[sid].ExtAddress.size ()?_IdCnx[sid].ExtAddress[connectionId].asString().c_str():"???");</font>
01055 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].CbNetBase->send (msgout, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].HostId);
01056 }
01057 }
01058
01059 <font class="keywordflow">if</font> (!found)
01060 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: can't find service %s to send message %s"</font>, serviceName.c_str(), msgout.getName().c_str());
01061
01062 <font class="keywordflow">return</font> found;
01063 }
01064
<a name="l01065"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a8">01065</a> <font class="keywordtype">bool</font> CUnifiedNetwork::send(uint16 sid, <font class="keyword">const</font> CMessage &msgout, uint8 nid)
01066 {
01067 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::send(uint16, const CMessage&) whereas it is not initialised yet"</font>));
01068
01069 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
01070
01071 <font class="keywordflow">if</font> (sid >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size () || <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State != CUnifiedNetwork::CUnifiedConnection::Ready)
01072 {
01073 <font class="comment">// happen when trying to send a message to an unknown service id</font>
01074 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send to the service '%hu' because not in _IdCnx"</font>, sid);
01075 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01076 }
01077
01078 uint8 connectionId = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c7">findConnectionId</a> (sid, nid);
01079 <font class="keywordflow">if</font> (connectionId == 0xff) <font class="comment">// failed</font>
01080 {
01081 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send to the service '%hu' because no connection available"</font>, sid);
01082 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01083 }
01084
01085 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].CbNetBase->send (msgout, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].HostId);
01086 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01087 }
01088
<a name="l01089"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a9">01089</a> <font class="keywordtype">void</font> CUnifiedNetwork::send(<font class="keyword">const</font> CMessage &msgout, uint8 nid)
01090 {
01091 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::send(const CMessage&) whereas it is not initialised yet"</font>));
01092
01093 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
01094
01095 uint i;
01096 <font class="keywordflow">for</font> (i=0; i<<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size(); ++i)
01097 {
01098 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01099 {
01100 uint8 connectionId = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c7">findConnectionId</a> (i, nid);
01101 <font class="keywordflow">if</font> (connectionId == 0xff) <font class="comment">// failed</font>
01102 {
01103 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't send message to %u because no connection available"</font>, i);
01104 <font class="keywordflow">continue</font>;
01105 }
01106
01107 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[connectionId].CbNetBase->send (msgout, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[connectionId].HostId);
01108 }
01109 }
01110 }
01111
01112
01113 <font class="comment">//</font>
01114 <font class="comment">//</font>
01115 <font class="comment">//</font>
01116
<a name="l01117"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a5">01117</a> <font class="keywordtype">void</font> CUnifiedNetwork::addCallbackArray (<font class="keyword">const</font> TUnifiedCallbackItem *callbackarray, CStringIdArray::TStringId arraysize)
01118 {
01119 uint i;
01120
01121 <font class="keywordflow">for</font> (i=0; i<(uint)arraysize; ++i)
01122 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o12">_Callbacks</a>.insert(make_pair(string(callbackarray[i].Key),callbackarray[i].Callback));
01123 }
01124
01125
01126 <font class="keywordtype">void</font> CUnifiedNetwork::setServiceUpCallback (<font class="keyword">const</font> string &serviceName, <a class="code" href="namespaceNLNET.html#a25">TUnifiedNetCallback</a> cb, <font class="keywordtype">void</font> *arg, <font class="keywordtype">bool</font> back)
01127 {
01128 <font class="keywordflow">if</font> (serviceName == <font class="stringliteral">"*"</font>)
01129 {
01130 <a class="code" href="debug_8h.html#a6">nlassert</a> (cb != NULL);
01131 <font class="keywordflow">if</font> (back)
01132 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>.push_back (make_pair(cb, arg));
01133 <font class="keywordflow">else</font>
01134 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>.insert (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o6">_UpUniCallback</a>.begin(), make_pair(cb, arg));
01135
01136 <font class="keywordflow">return</font>;
01137 }
01138
01139 TNameMappedCallback::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.find(serviceName);
01140 <font class="keywordflow">if</font> (it == <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.end())
01141 {
01142 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#u1">TCallbackArgItem</a> ncb;
01143 ncb.first = NULL;
01144 ncb.second = NULL;
01145 it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o5">_UpCallbacks</a>.insert(make_pair(serviceName, ncb));
01146 }
01147
01148 (*it).second.first = cb;
01149 (*it).second.second = arg;
01150 }
01151
01152 <font class="keywordtype">void</font> CUnifiedNetwork::setServiceDownCallback (<font class="keyword">const</font> string &serviceName, <a class="code" href="namespaceNLNET.html#a25">TUnifiedNetCallback</a> cb, <font class="keywordtype">void</font> *arg, <font class="keywordtype">bool</font> back)
01153 {
01154 <font class="keywordflow">if</font> (serviceName == <font class="stringliteral">"*"</font>)
01155 {
01156 <a class="code" href="debug_8h.html#a6">nlassert</a> (cb != NULL);
01157 <font class="keywordflow">if</font> (back)
01158 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o8">_DownUniCallback</a>.push_back (make_pair(cb, arg));
01159 <font class="keywordflow">else</font>
01160 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o8">_DownUniCallback</a>.insert (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o8">_DownUniCallback</a>.begin(), make_pair(cb, arg));
01161
01162 <font class="keywordflow">return</font>;
01163 }
01164
01165 TNameMappedCallback::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o7">_DownCallbacks</a>.find(serviceName);
01166 <font class="keywordflow">if</font> (it == <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o7">_DownCallbacks</a>.end())
01167 {
01168 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#u1">TCallbackArgItem</a> ncb;
01169 ncb.first = NULL;
01170 ncb.second = NULL;
01171 it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o7">_DownCallbacks</a>.insert(make_pair(serviceName, ncb));
01172 }
01173
01174 (*it).second.first = cb;
01175 (*it).second.second = arg;
01176 }
01177
01178 <font class="comment">//</font>
01179 <font class="comment">//</font>
01180 <font class="comment">//</font>
01181
<a name="l01182"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a20">01182</a> uint64 CUnifiedNetwork::getBytesSent ()
01183 {
01184 uint64 sent = 0;
01185 uint j;
01186
01187 <font class="keywordflow">for</font> (vector<uint16>::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.begin (); it != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.end(); it++)
01188 {
01189 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01190 <font class="keywordflow">for</font> (j=0; j<<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection.size (); ++j)
01191 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].valid () && !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].IsServerConnection)
01192 sent += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].CbNetBase->getBytesSent();
01193 }
01194
01195 <font class="comment">/* for (i=0; i<_IdCnx.size(); ++i)</font>
01196 <font class="comment"> if (_IdCnx[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)</font>
01197 <font class="comment"> for (j=0; j<_IdCnx[i].Connection.size (); ++j)</font>
01198 <font class="comment"> if(_IdCnx[i].Connection[j].valid () && !_IdCnx[i].Connection[j].IsServerConnection)</font>
01199 <font class="comment"> sent += _IdCnx[i].Connection[j].CbNetBase->getBytesSent();</font>
01200 <font class="comment">*/</font>
01201 <font class="keywordflow">if</font>(_CbServer)
01202 sent += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->getBytesSent();
01203 <font class="keywordflow">return</font> sent;
01204 }
01205
<a name="l01206"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a21">01206</a> uint64 CUnifiedNetwork::getBytesReceived ()
01207 {
01208 uint64 received = 0;
01209 uint j;
01210
01211 <font class="keywordflow">for</font> (vector<uint16>::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.begin (); it != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.end(); it++)
01212 {
01213 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01214 <font class="keywordflow">for</font> (j=0; j<<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection.size (); ++j)
01215 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].valid () && !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].IsServerConnection)
01216 received += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].CbNetBase->getBytesReceived();
01217 }
01218
01219 <font class="comment">/* for (i=0; i<_IdCnx.size(); ++i)</font>
01220 <font class="comment"> if (_IdCnx[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)</font>
01221 <font class="comment"> for (j=0; j<_IdCnx[i].Connection.size (); ++j)</font>
01222 <font class="comment"> if(_IdCnx[i].Connection[j].valid () && !_IdCnx[i].Connection[j].IsServerConnection)</font>
01223 <font class="comment"> received += _IdCnx[i].Connection[j].CbNetBase->getBytesReceived();</font>
01224 <font class="comment">*/</font>
01225 <font class="keywordflow">if</font> (_CbServer)
01226 received += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->getBytesReceived();
01227 <font class="keywordflow">return</font> received;
01228 }
01229
<a name="l01230"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a22">01230</a> uint64 CUnifiedNetwork::getSendQueueSize ()
01231 {
01232 uint64 sent = 0;
01233 uint j;
01234
01235 <font class="keywordflow">for</font> (vector<uint16>::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.begin (); it != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.end(); it++)
01236 {
01237 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01238 <font class="keywordflow">for</font> (j=0; j<<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection.size (); ++j)
01239 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].valid () && !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].IsServerConnection)
01240 sent += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].CbNetBase->getSendQueueSize();
01241 }
01242
01243 <font class="comment">/* for (i=0; i<_IdCnx.size(); ++i)</font>
01244 <font class="comment"> if (_IdCnx[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)</font>
01245 <font class="comment"> for (j=0; j<_IdCnx[i].Connection.size (); ++j)</font>
01246 <font class="comment"> if(_IdCnx[i].Connection[j].valid () && !_IdCnx[i].Connection[j].IsServerConnection)</font>
01247 <font class="comment"> sent += _IdCnx[i].Connection[j].CbNetBase->getSendQueueSize();</font>
01248 <font class="comment">*/</font>
01249 <font class="keywordflow">if</font> (_CbServer)
01250 sent += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->getSendQueueSize();
01251 <font class="keywordflow">return</font> sent;
01252 }
01253
<a name="l01254"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a23">01254</a> uint64 CUnifiedNetwork::getReceiveQueueSize ()
01255 {
01256 uint64 received = 0;
01257 uint j;
01258
01259 <font class="keywordflow">for</font> (vector<uint16>::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.begin (); it != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.end(); it++)
01260 {
01261 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01262 <font class="keywordflow">for</font> (j=0; j<<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection.size (); ++j)
01263 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].valid () && !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].IsServerConnection)
01264 received += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*it)].Connection[j].CbNetBase->getReceiveQueueSize();
01265 }
01266
01267 <font class="comment">/* for (i=0; i<_IdCnx.size(); ++i)</font>
01268 <font class="comment"> if (_IdCnx[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)</font>
01269 <font class="comment"> for (j=0; j<_IdCnx[i].Connection.size (); ++j)</font>
01270 <font class="comment"> if(_IdCnx[i].Connection[j].valid () && !_IdCnx[i].Connection[j].IsServerConnection)</font>
01271 <font class="comment"> received += _IdCnx[i].Connection[j].CbNetBase->getReceiveQueueSize();</font>
01272 <font class="comment">*/</font>
01273 <font class="keywordflow">if</font> (_CbServer)
01274 received += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o3">_CbServer</a>->getReceiveQueueSize();
01275 <font class="keywordflow">return</font> received;
01276 }
01277
<a name="l01278"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a18">01278</a> CCallbackNetBase *CUnifiedNetwork::getNetBase(<font class="keyword">const</font> std::string &name, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> &host, uint8 nid)
01279 {
01280 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::getNetBase() whereas it is not initialised yet"</font>));
01281
01282 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
01283
01284 sint count = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.count(name);
01285
01286 <font class="keywordflow">if</font> (count <= 0)
01287 {
01288 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: couldn't access the service %s"</font>, name.c_str());
01289 host = InvalidSockId;
01290 <font class="keywordflow">return</font> NULL;
01291 }
01292 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (count > 1)
01293 {
01294 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: %d services %s to getNetBase, returns the first valid"</font>, count, name.c_str());
01295 }
01296
01297 TNameMappedConnection::const_iterator itnmc = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.find(name);
01298
01299 uint8 connectionId = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c7">findConnectionId</a> ((*itnmc).second, nid);
01300 <font class="keywordflow">if</font> (connectionId == 0xff) <font class="comment">// failed</font>
01301 {
01302 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Can't getNetBase %s because no connection available"</font>, name.c_str());
01303 host = InvalidSockId;
01304 <font class="keywordflow">return</font> NULL;
01305 }
01306
01307 host = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itnmc).second].Connection[connectionId].HostId;
01308 <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itnmc).second].Connection[connectionId].CbNetBase;
01309 }
01310
<a name="l01311"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a19">01311</a> CCallbackNetBase *CUnifiedNetwork::getNetBase(uint16 sid, <a class="code" href="namespaceNLNET.html#a0">TSockId</a> &host, uint8 nid)
01312 {
01313 <a class="code" href="debug_8h.html#a8">nlassertex</a>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o17">_Initialised</a> == <font class="keyword">true</font>, (<font class="stringliteral">"Try to CUnifiedNetwork::getNetBase() whereas it is not initialised yet"</font>));
01314
01315 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a> != <a class="code" href="namespaceNLMISC.html#a237">NLMISC::getThreadId</a>()) <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Multithread access but this class is not thread safe thread creator = %u thread used = %u"</font>, <a class="code" href="namespaceNLNET.html#a68">ThreadCreator</a>, NLMISC::getThreadId());
01316
01317 <font class="keywordflow">if</font> (sid >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size () || <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State != CUnifiedNetwork::CUnifiedConnection::Ready)
01318 {
01319 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"HNETL5: Can't get net base to the service '%hu' because not in _IdCnx"</font>, sid);
01320 host = InvalidSockId;
01321 <font class="keywordflow">return</font> NULL;
01322 }
01323
01324 uint8 connectionId = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c7">findConnectionId</a> (sid, nid);
01325 <font class="keywordflow">if</font> (connectionId == 0xff) <font class="comment">// failed</font>
01326 {
01327 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Can't getNetBase %hu because no connection available"</font>, sid);
01328 host = InvalidSockId;
01329 <font class="keywordflow">return</font> NULL;
01330 }
01331
01332 host = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].HostId;
01333 <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].Connection[connectionId].CbNetBase;
01334 }
01335
<a name="l01336"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a24">01336</a> <a class="code" href="namespaceNLNET.html#a26">TUnifiedMsgCallback</a> CUnifiedNetwork::findCallback (<font class="keyword">const</font> std::string &callbackName)
01337 {
01338 TMsgMappedCallback::iterator itcb = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o12">_Callbacks</a>.find(callbackName);
01339 <font class="keywordflow">if</font> (itcb == <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o12">_Callbacks</a>.end())
01340 <font class="keywordflow">return</font> NULL;
01341 <font class="keywordflow">else</font>
01342 <font class="keywordflow">return</font> (*itcb).second;
01343 }
01344
<a name="l01345"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a17">01345</a> <font class="keywordtype">bool</font> CUnifiedNetwork::isServiceLocal (<font class="keyword">const</font> std::string &serviceName)
01346 {
01347 <font class="comment">// it s me, of course we are local</font>
01348 <font class="keywordflow">if</font> (serviceName == <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o11">_Name</a>)
01349 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01350
01351 pair<TNameMappedConnection::const_iterator,TNameMappedConnection::const_iterator> <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>;
01352 <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a> = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.equal_range(serviceName);
01353
01354 <font class="keywordtype">bool</font> found = <font class="keyword">false</font>;
01355 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.end())
01356 {
01357 uint16 sid = (*(<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first)).second;
01358 <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a16">isServiceLocal</a> (sid);
01359 }
01360
01361 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01362 }
01363
<a name="l01364"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a16">01364</a> <font class="keywordtype">bool</font> CUnifiedNetwork::isServiceLocal (uint16 sid)
01365 {
01366 <font class="comment">// it s me, of course we are local</font>
01367 <font class="keywordflow">if</font> (sid == <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o10">_SId</a>)
01368 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01369
01370 <font class="keywordflow">if</font> (sid >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size () || <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State != CUnifiedNetwork::CUnifiedConnection::Ready)
01371 {
01372 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01373 }
01374
01375 vector<CInetAddress> laddr = CInetAddress::localAddresses();
01376
01377 <font class="keywordflow">for</font> (uint i = 0; i < laddr.size(); i++)
01378 {
01379 <font class="keywordflow">for</font> (uint j = 0; j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ExtAddress.size(); j++)
01380 {
01381 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ExtAddress[j].is127001 ())
01382 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01383
01384 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ExtAddress[j].internalIPAddress () == laddr[i].internalIPAddress ())
01385 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01386 }
01387 }
01388 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01389 }
01390
01391 <font class="comment">//</font>
01392 <font class="comment">//</font>
01393 <font class="comment">//</font>
01394
<a name="l01395"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#r0">01395</a> CUnifiedNetwork *CUnifiedNetwork::_Instance = NULL;
01396
<a name="l01397"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#d0">01397</a> CUnifiedNetwork *CUnifiedNetwork::getInstance ()
01398 {
01399 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#r0">_Instance</a> == NULL)
01400 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#r0">_Instance</a> = <font class="keyword">new</font> <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c0">CUnifiedNetwork</a>();
01401
01402 <font class="keywordflow">return</font> <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#r0">_Instance</a>;
01403 }
01404
<a name="l01405"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#d1">01405</a> <font class="keywordtype">bool</font> CUnifiedNetwork::isUsed ()
01406 {
01407 <font class="keywordflow">return</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#r0">_Instance</a> != NULL);
01408 }
01409
01410 <font class="comment">//</font>
01411 <font class="comment">//</font>
01412 <font class="comment">//</font>
01413
<a name="l01414"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c3">01414</a> CUnifiedNetwork::CUnifiedConnection *CUnifiedNetwork::getUnifiedConnection (uint16 sid)
01415 {
01416 <font class="keywordflow">if</font> (sid < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size () && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].State == CUnifiedConnection::Ready)
01417 {
01418 <font class="keywordflow">if</font> (sid != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ServiceId)
01419 {
01420 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"Sid index %hu is not the same that in the entry %hu"</font>, sid, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid].ServiceId);
01421 <font class="keywordflow">return</font> NULL;
01422 }
01423 <font class="keywordflow">return</font> &<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[sid];
01424 }
01425 <font class="keywordflow">else</font>
01426 {
01427 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Try to get a bad unified connection (sid %hu is not in the table)"</font>, sid);
01428 <font class="keywordflow">return</font> NULL;
01429 }
01430 }
01431
<a name="l01432"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c2">01432</a> <font class="keywordtype">void</font> CUnifiedNetwork::autoCheck()
01433 {
01434 uint i, j;
01435
01436 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size (); i++)
01437 {
01438 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01439 {
01440 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].AutoCheck = 1;
01441 }
01442 <font class="keywordflow">else</font>
01443 {
01444 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].AutoCheck = 0;
01445 }
01446 }
01447
01448 TNameMappedConnection::iterator itn;
01449 <font class="keywordflow">for</font> (itn = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.begin(); itn != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.end(); ++itn)
01450 {
01451 <font class="keywordflow">if</font> ((*itn).first != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itn).second].ServiceName) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: problem with name syncro between _NameCnx and _IdCnx '%s' '%s' '%d'"</font>, (*itn).first.c_str(), <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itn).second].ServiceName.c_str (), (*itn).second);
01452 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itn).second].AutoCheck == 0) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: problem with name syncro between _NameCnx '%s' and _IdCnx '%s' '%d'"</font>, (*itn).first.c_str(), <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itn).second].ServiceName.c_str (), (*itn).second);
01453 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itn).second].AutoCheck > 1) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: problem with name syncro between _NameCnx and _IdCnx '%s' '%d' more than one entry in named with the same name"</font>, (*itn).first.c_str(), <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itn).second].ServiceName.c_str (),(*itn).second);
01454 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[(*itn).second].AutoCheck++;
01455 }
01456
01457 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.size (); i++)
01458 {
01459 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>[i]].State != CUnifiedNetwork::CUnifiedConnection::Ready) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: problem with the _UsedConnection syncro sid %d is not used in _IdCnx"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>[i]);
01460 }
01461
01462 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size (); i++)
01463 {
01464 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01465 {
01466 <font class="keywordflow">for</font> (j = 0; j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.size (); j++)
01467 {
01468 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>[j] == i) <font class="keywordflow">break</font>;
01469 }
01470 <font class="keywordflow">if</font> (j == <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.size ()) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: problem with the _UsedConnection syncro sid %d is not in _UsedConnection"</font>, i);
01471 }
01472 }
01473
01474 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size (); i++)
01475 {
01476 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State == CUnifiedNetwork::CUnifiedConnection::NotUsed)
01477 {
01478 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceName != <font class="stringliteral">"DEAD"</font>) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d name should be DEAD and is '%s'"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceName.c_str ());
01479 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceId != 0xDEAD) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d sid should be 0xDEAD and is 0x%X"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceId);
01480 <font class="keywordflow">if</font> (!<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.empty ()) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d connection size should be 0 and is %d"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size ());
01481 <font class="keywordflow">if</font> (!<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.empty ()) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d ext addr size should be 0 and is %d"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.size ());
01482 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].AutoCheck != 0) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d prob with syncro with _NamedCnx"</font>, i);
01483 }
01484 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State == CUnifiedNetwork::CUnifiedConnection::Ready)
01485 {
01486 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceId != i) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HNETL5: Bad syncro sid index sid entry for %d %d"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceId);
01487
01488 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceName == <font class="stringliteral">"DEAD"</font>) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d name should not be DEAD and is '%s'"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceName.c_str ());
01489 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceId == 0xDEAD) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d sid should not be 0xDEAD and is 0x%X"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceId);
01490 <font class="keywordflow">if</font> (!<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.empty () && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size () > <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.size()) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d ext addr size should not be 0 and is %d"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.size ());
01491
01492 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].AutoRetry == <font class="keyword">true</font> && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size () > 1) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d auto retry with more than one connection %d"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size ());
01493 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].AutoRetry == <font class="keyword">true</font> && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].IsExternal == <font class="keyword">false</font>) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d auto retry with internal connection"</font>, i);
01494 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].AutoRetry == <font class="keyword">true</font> && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[0].valid() == <font class="keyword">false</font>) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d auto retry with invalid connection"</font>, i);
01495
01496 <font class="keywordflow">for</font> (j = 0; j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size (); j++)
01497 {
01498 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].valid() && !<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].IsServerConnection && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].CbNetBase->connected () && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].getAppId() != i) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d bad appid %"</font>NL_I64<font class="stringliteral">"X"</font>, i, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].getAppId());
01499 }
01500
01501 <font class="keywordflow">for</font> (j = 0; j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].NetworkConnectionAssociations.size (); j++)
01502 {
01503 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].NetworkConnectionAssociations[j] != 0)
01504 {
01505 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>[j] != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress[<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].NetworkConnectionAssociations[j]].internalNetAddress ()) <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"HLNET5: sid %d nid %d have address 0x%08x and is not the good connection net 0x%08x"</font>, i, j, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>[j], <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress[<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].NetworkConnectionAssociations[j]].internalNetAddress ());
01506 }
01507 }
01508 }
01509 }
01510 }
01511
01512
<a name="l01513"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#a25">01513</a> <font class="keywordtype">void</font> CUnifiedNetwork::displayInternalTables (<a class="code" href="classNLMISC_1_1CLog.html">NLMISC::CLog</a> *log)
01514 {
01515 uint i, j;
01516 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"%d Named Connections:"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.size ());
01517 <font class="keywordflow">for</font> (TNameMappedConnection::iterator it = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.begin(); it != <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.end (); it++)
01518 {
01519 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"> '%s' -> %hu"</font>, (*it).first.c_str(), (*it).second);
01520 }
01521
01522 uint nbused = 0;
01523 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size (); i++)
01524 {
01525 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State != CUnifiedNetwork::CUnifiedConnection::NotUsed)
01526 nbused++;
01527 }
01528
01529 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"%u/%u Unified Connections:"</font>, nbused, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size ());
01530 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>.size (); i++)
01531 {
01532 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].State != CUnifiedNetwork::CUnifiedConnection::NotUsed)
01533 {
01534 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"> %s-%hu %s %s %s (%d extaddr %d cnx)"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceName.c_str (), <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ServiceId, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].IsExternal?<font class="stringliteral">"ext"</font>:<font class="stringliteral">"int"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].AutoRetry?<font class="stringliteral">"autoretry"</font>:<font class="stringliteral">"noautoretry"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].SendId?<font class="stringliteral">"sendid"</font>:<font class="stringliteral">"nosendid"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.size (), <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size ());
01535 uint maxc = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size ();
01536 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size () <= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.size ())
01537 maxc = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.size ();
01538
01539 <font class="keywordflow">for</font> (j = 0; j < maxc; j++)
01540 {
01541 string base;
01542 <font class="keywordflow">if</font>(j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress.size ())
01543 {
01544 base += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].ExtAddress[j].asString ();
01545 }
01546 <font class="keywordflow">else</font>
01547 {
01548 base += <font class="stringliteral">"notvalid"</font>;
01549 }
01550
01551 string ext;
01552 <font class="keywordflow">if</font>(j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection.size () && <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].valid())
01553 {
01554 <font class="keywordflow">if</font>(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].IsServerConnection)
01555 {
01556 ext += <font class="stringliteral">"server "</font>;
01557 }
01558 <font class="keywordflow">else</font>
01559 {
01560 ext += <font class="stringliteral">"client "</font>;
01561 }
01562 ext += <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].CbNetBase->getSockId (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].HostId)->asString ();
01563 ext += <font class="stringliteral">" appid:"</font> + toString(<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].getAppId());
01564 <font class="keywordflow">if</font> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].Connection[j].CbNetBase->connected ())
01565 ext += <font class="stringliteral">" connected"</font>;
01566 <font class="keywordflow">else</font>
01567 ext += <font class="stringliteral">" notconnected"</font>;
01568 }
01569 <font class="keywordflow">else</font>
01570 {
01571 ext += <font class="stringliteral">"notvalid"</font>;
01572 }
01573
01574 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">" - %s %s"</font>, base.c_str (), ext.c_str ());
01575 }
01576 <font class="keywordflow">for</font> (j = 0; j < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].NetworkConnectionAssociations.size (); j++)
01577 {
01578 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">" * nid %d -> cnxn %hu"</font>, j, (uint16)<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o0">_IdCnx</a>[i].NetworkConnectionAssociations[j]);
01579 }
01580 }
01581 }
01582
01583 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"%u Used Unified Connections:"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.size());
01584 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>.size (); i++)
01585 {
01586 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"> %hu"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o1">_UsedConnection</a>[i]);
01587 }
01588
01589 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"%u Network Associations:"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>.size());
01590 <font class="keywordflow">for</font> (i = 0; i < <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>.size (); i++)
01591 {
01592 log-><a class="code" href="classNLMISC_1_1CLog.html#a8">displayNL</a> (<font class="stringliteral">"> 0x%08x -> '%s'"</font>, <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>[i], <a class="code" href="namespaceNLNET.html#a81">internalIPAddressToString</a> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>[i]).c_str ());
01593 }
01594 }
01595
<a name="l01596"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c4">01596</a> <font class="keywordtype">bool</font> CUnifiedNetwork::haveNamedCnx (<font class="keyword">const</font> std::string &name, uint16 sid)
01597 {
01598 CUnifiedNetwork::TNameMappedConnection::iterator it;
01599 pair<CUnifiedNetwork::TNameMappedConnection::iterator,CUnifiedNetwork::TNameMappedConnection::iterator> <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>;
01600 <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a> = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.equal_range(name);
01601
01602 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first != <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second)
01603 {
01604 <font class="keywordflow">for</font> (it=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first; it!=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second && (*it).second!=sid; ++it)
01605 ;
01606
01607 <font class="keywordflow">return</font> (it != <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second);
01608 }
01609 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01610 }
01611
<a name="l01612"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c5">01612</a> <font class="keywordtype">void</font> CUnifiedNetwork::addNamedCnx (<font class="keyword">const</font> std::string &name, uint16 sid)
01613 {
01614 <font class="comment">// check if not already inserted</font>
01615 CUnifiedNetwork::TNameMappedConnection::iterator it;
01616 pair<CUnifiedNetwork::TNameMappedConnection::iterator,CUnifiedNetwork::TNameMappedConnection::iterator> <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>;
01617 <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a> = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.equal_range(name);
01618
01619 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first != <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second)
01620 {
01621 <font class="keywordflow">for</font> (it=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first; it!=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second && (*it).second!=sid; ++it)
01622 ;
01623
01624 <font class="keywordflow">if</font> (it != <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second)
01625 {
01626 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"Try to add 2 times the same connection %s-%hu"</font>, name.c_str(), sid);
01627 <font class="keywordflow">return</font>;
01628 }
01629 }
01630
01631
01632 <font class="comment">// insert the name in the map to be able to send message with the name</font>
01633 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.insert(make_pair(name, sid));
01634
01635 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"+name "</font>+name+<font class="stringliteral">"-"</font>+toString(sid)+<font class="stringliteral">"\n"</font>;
01636 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"+name %s-%hu"</font>, name.c_str (), sid);
01637 }
01638
<a name="l01639"></a><a class="code" href="classNLNET_1_1CUnifiedNetwork.html#c6">01639</a> <font class="keywordtype">void</font> CUnifiedNetwork::removeNamedCnx (<font class="keyword">const</font> std::string &name, uint16 sid)
01640 {
01641 <font class="comment">// get all map nodes of that service name</font>
01642 CUnifiedNetwork::TNameMappedConnection::iterator it;
01643 pair<CUnifiedNetwork::TNameMappedConnection::iterator,CUnifiedNetwork::TNameMappedConnection::iterator> <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>;
01644 <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a> = <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.equal_range(name);
01645
01646 <font class="comment">// assume not empty</font>
01647 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first == <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second)
01648 {
01649 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"The unified connection %s-%hu wasn't on the _NamedCnx"</font>, name.c_str(), sid);
01650 <font class="keywordflow">return</font>;
01651 }
01652
01653 <font class="comment">// select good service id</font>
01654 <font class="keywordflow">for</font> (it=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.first; it!=<a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second && (*it).second!=sid; ++it)
01655 ;
01656
01657 <font class="comment">// assume id exists</font>
01658 <font class="keywordflow">if</font> (it == <a class="code" href="driver__opengl__extension__def_8h.html#a412">range</a>.second)
01659 {
01660 <a class="code" href="unified__network_8cpp.html#a0">AUTOCHECK_DISPLAY</a> (<font class="stringliteral">"The unified connection %s-%hu wasn't on the _NamedCnx"</font>, name.c_str(), sid);
01661 <font class="keywordflow">return</font>;
01662 }
01663
01664 <font class="comment">// remove service for map</font>
01665 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o2">_NamedCnx</a>.erase(it);
01666
01667 <a class="code" href="namespaceNLNET.html#a70">allstuffs</a> += <font class="stringliteral">"-name "</font>+name+<font class="stringliteral">"-"</font>+toString(sid)+<font class="stringliteral">"\n"</font>;
01668 <a class="code" href="namespaceNLNET.html#a141">test</a>.displayNL (<font class="stringliteral">"-name %s-%hu"</font>, name.c_str (), sid);
01669 }
01670
01671 <font class="keywordtype">void</font> CUnifiedNetwork::addNetworkAssociation (<font class="keyword">const</font> string &networkName, uint8 nid)
01672 {
01673 <font class="keywordflow">if</font> (nid >= <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>.size ())
01674 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>.resize (nid+1, 0xFF);
01675
01676 <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>[nid] = <a class="code" href="namespaceNLNET.html#a80">stringToInternalIPAddress</a> (networkName);
01677 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"HNETL5: Associate network '%s' 0x%08x '%s' to nid %hu"</font>, networkName.c_str(), <a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>[nid], <a class="code" href="namespaceNLNET.html#a81">internalIPAddressToString</a> (<a class="code" href="classNLNET_1_1CUnifiedNetwork.html#o18">_NetworkAssociations</a>[nid]).c_str(), (uint16)nid);
01678 }
01679
01680
01681
01682 <font class="comment">//</font>
01683 <font class="comment">//</font>
01684 <font class="comment">//</font>
01685
01686
01687 <font class="comment">//</font>
01688 <font class="comment">// Commands</font>
01689 <font class="comment">//</font>
01690
01691 <font class="keyword">static</font> <font class="keywordtype">bool</font> <a class="code" href="namespaceNLNET.html#a148">createMessage</a> (CMessage &msgout, <font class="keyword">const</font> vector<string> &args, CLog &log)
01692 {
01693 <font class="keywordflow">for</font> (uint i = 2; i < args.size (); i+=2)
01694 {
01695 string <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> = args[i+0];
01696 string <a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a> = args[i+1];
01697
01698 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"s8"</font>) { sint8 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01699 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"s16"</font>) { sint16 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01700 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"s32"</font>) { sint32 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01701 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"s64"</font>) { sint64 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01702 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"u8"</font>) { uint8 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01703 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"u16"</font>) { uint16 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01704 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"u32"</font>) { uint32 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01705 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"u64"</font>) { uint64 <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01706 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"f"</font>) { <font class="keywordtype">float</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = (float)atof(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01707 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"d"</font>) { <font class="keywordtype">double</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atof(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()); msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01708 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"b"</font>) { <font class="keywordtype">bool</font> <a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a> = atoi(<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>.c_str()) == 1; msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a368">v</a>); }
01709 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a> == <font class="stringliteral">"s"</font>) { msgout.serial (<a class="code" href="driver__opengl__extension__def_8h.html#a415">value</a>); }
01710 <font class="keywordflow">else</font> { log.displayNL (<font class="stringliteral">"type '%s' is not a valid type"</font>, <a class="code" href="driver__opengl__extension__def_8h.html#a373">type</a>.c_str()); <font class="keywordflow">return</font> <font class="keyword">false</font>; }
01711 }
01712 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01713 }
01714
01715 <font class="comment">/*</font>
01716 <font class="comment"> * Simulate a message that comes from the network.</font>
01717 <font class="comment"> *</font>
01718 <font class="comment"> * for the bool (b type), you must set the value to 1 or 0</font>
01719 <font class="comment"> * for the string (s type), we don't manage space inside a string</font>
01720 <font class="comment"> * for stl containers, you have first to put a u32 type that is the size of the container and after all elements</font>
01721 <font class="comment"> * (ex: if you want to put a vector<uint16> that have 3 elements: u32 3 u16 10 u16 11 u16 12)</font>
01722 <font class="comment"> *</font>
01723 <font class="comment"> * ex: msgin 128 REGISTER u32 10 u32 541 u32 45</font>
01724 <font class="comment"> * You'll receive a fake message REGISTER that seems to come from the service number 128 with 3 uint32.</font>
01725 <font class="comment"> *</font>
01726 <font class="comment"> */</font>
01727
01728 <a class="code" href="namespaceNLNET.html#a111">NLMISC_COMMAND</a>(msgin, <font class="stringliteral">"Simulate an input message from another service (ex: msgin 128 REGISTER u32 10 b 1 f 1.5)"</font>, <font class="stringliteral">"<ServiceName>|<ServiceId> <MessageName> [<ParamType> <Param>]*"</font>)
01729 {
01730 <font class="keywordflow">if</font>(args.size() < 2) <font class="keywordflow">return</font> <font class="keyword">false</font>;
01731
01732 <font class="keywordflow">if</font> (!CUnifiedNetwork::isUsed ())
01733 {
01734 log.displayNL(<font class="stringliteral">"Can't do that because the service doesn't use CUnifiedNetwork"</font>);
01735 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01736 }
01737
01738 uint16 serviceId = atoi (args[0].c_str());
01739 string serviceName = args[0].c_str();
01740 string messageName = args[1].c_str();
01741
01742 <font class="keywordflow">if</font> (serviceId > 255)
01743 {
01744 log.displayNL (<font class="stringliteral">"Service Id %d must be between [1;255]"</font>, serviceId);
01745 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01746 }
01747
01748 <font class="keywordflow">if</font> ((args.size()-2) % 2 != 0)
01749 {
01750 log.displayNL (<font class="stringliteral">"The number of parameter must be a multiple of 2"</font>);
01751 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01752 }
01753
01754 CMessage msg (messageName);
01755 msg.clear ();
01756
01757 <font class="keywordflow">if</font> (!<a class="code" href="namespaceNLNET.html#a148">createMessage</a> (msg, args, log))
01758 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01759
01760 msg.invert ();
01761
01762 <a class="code" href="namespaceNLNET.html#a26">TUnifiedMsgCallback</a> cb = CUnifiedNetwork::getInstance()->findCallback (messageName);
01763
01764 <font class="keywordflow">if</font> (cb == NULL)
01765 {
01766 log.displayNL (<font class="stringliteral">"Callback for message '%s' is not found"</font>, messageName.c_str());
01767 }
01768 <font class="keywordflow">else</font>
01769 {
01770 cb (msg, serviceName, serviceId);
01771 }
01772
01773
01774 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01775 }
01776
01777 <font class="comment">/*</font>
01778 <font class="comment"> * Create a message and send it to the specified service</font>
01779 <font class="comment"> *</font>
01780 <font class="comment"> * for the bool (b type), you must set the value to 1 or 0</font>
01781 <font class="comment"> * for the string (s type), we don't manage space inside a string</font>
01782 <font class="comment"> * for stl containers, you have first to put a u32 type that is the size of the container and after all elements</font>
01783 <font class="comment"> * (ex: if you want to put a vector<uint16> that have 3 elements: u32 3 u16 10 u16 11 u16 12)</font>
01784 <font class="comment"> *</font>
01785 <font class="comment"> * ex: msgout 128 REGISTER u32 10 u32 541 u32 45</font>
01786 <font class="comment"> * You'll send a real message REGISTER to the service number 128 with 3 uint32.</font>
01787 <font class="comment"> *</font>
01788 <font class="comment"> */</font>
01789
01790 <a class="code" href="namespaceNLNET.html#a111">NLMISC_COMMAND</a>(msgout, <font class="stringliteral">"Send a message to a specified service (ex: msgout 128 REGISTER u32 10 b 1 f 1.5)"</font>, <font class="stringliteral">"<ServiceName>|<ServiceId> <MessageName> [<ParamType> <Param>]*"</font>)
01791 {
01792 <font class="keywordflow">if</font>(args.size() < 2) <font class="keywordflow">return</font> <font class="keyword">false</font>;
01793
01794 <font class="keywordflow">if</font> (!CUnifiedNetwork::isUsed ())
01795 {
01796 log.displayNL(<font class="stringliteral">"Can't do that because the service doesn't use CUnifiedNetwork"</font>);
01797 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01798 }
01799
01800 uint16 serviceId = atoi (args[0].c_str());
01801 string serviceName = args[0].c_str();
01802 string messageName = args[1].c_str();
01803
01804 <font class="keywordflow">if</font> (serviceId > 255)
01805 {
01806 log.displayNL (<font class="stringliteral">"Service Id %d must be between [1;255]"</font>, serviceId);
01807 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01808 }
01809
01810 <font class="keywordflow">if</font> ((args.size()-2) % 2 != 0)
01811 {
01812 log.displayNL (<font class="stringliteral">"The number of parameter must be a multiple of 2"</font>);
01813 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01814 }
01815
01816 CMessage msg (messageName);
01817
01818 <font class="keywordflow">if</font> (!<a class="code" href="namespaceNLNET.html#a148">createMessage</a> (msg, args, log))
01819 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01820
01821 <a class="code" href="namespaceNLNET.html#a0">TSockId</a> host = InvalidSockId;
01822 CCallbackNetBase *cnb = NULL;
01823
01824 <font class="keywordflow">if</font> (serviceId != 0)
01825 cnb = CUnifiedNetwork::getInstance()->getNetBase ((uint8)serviceId, host);
01826 <font class="keywordflow">else</font>
01827 cnb = CUnifiedNetwork::getInstance()->getNetBase (serviceName, host);
01828
01829 <font class="keywordflow">if</font> (cnb == NULL)
01830 {
01831 log.displayNL (<font class="stringliteral">"'%s' is a bad <ServiceId> or <ServiceName>"</font>, args[0].c_str());
01832 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01833 }
01834
01835 cnb->send (msg, host);
01836
01837 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01838 }
01839
01840 <a class="code" href="namespaceNLNET.html#a111">NLMISC_COMMAND</a>(l5InternalTables, <font class="stringliteral">"Displays internal table of network layer5"</font>, <font class="stringliteral">""</font>)
01841 {
01842 <font class="keywordflow">if</font>(args.size() != 0) <font class="keywordflow">return</font> <font class="keyword">false</font>;
01843
01844 <font class="keywordflow">if</font> (!CUnifiedNetwork::isUsed ())
01845 {
01846 log.displayNL(<font class="stringliteral">"Can't display internal table because layer5 is not used"</font>);
01847 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01848 }
01849
01850 CUnifiedNetwork::getInstance ()->displayInternalTables(&log);
01851
01852 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01853 }
01854
01855 <a class="code" href="namespaceNLNET.html#a111">NLMISC_COMMAND</a>(isServiceLocal, <font class="stringliteral">"Says if a service is local or not compare with this service"</font>, <font class="stringliteral">"<sid>|<service name>"</font>)
01856 {
01857 <font class="keywordflow">if</font>(args.size() != 1) <font class="keywordflow">return</font> <font class="keyword">false</font>;
01858
01859 <font class="keywordflow">if</font> (!CUnifiedNetwork::isUsed ())
01860 {
01861 log.displayNL(<font class="stringliteral">"Can't do that because the service doesn't use CUnifiedNetwork"</font>);
01862 <font class="keywordflow">return</font> <font class="keyword">false</font>;
01863 }
01864
01865 uint16 sid = atoi (args[0].c_str ());
01866 <font class="keywordflow">if</font> (sid > 0)
01867 {
01868 log.displayNL (<font class="stringliteral">"Service %s-%hu and sid %s are %son the same computer"</font>, CUnifiedNetwork::getInstance ()->_Name.c_str(), (uint16)CUnifiedNetwork::getInstance ()->_SId, args[0].c_str(), CUnifiedNetwork::getInstance ()->isServiceLocal (sid)?<font class="stringliteral">""</font>:<font class="stringliteral">"not "</font>);
01869 }
01870 <font class="keywordflow">else</font>
01871 {
01872 log.displayNL (<font class="stringliteral">"Service %s-%hu and %s are %son the same computer"</font>, CUnifiedNetwork::getInstance ()->_Name.c_str(), (uint16)CUnifiedNetwork::getInstance ()->_SId, args[0].c_str(), CUnifiedNetwork::getInstance ()->isServiceLocal (args[0])?<font class="stringliteral">""</font>:<font class="stringliteral">"not "</font>);
01873 }
01874
01875 <font class="keywordflow">return</font> <font class="keyword">true</font>;
01876 }
01877
01878 } <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>
|