-
Notifications
You must be signed in to change notification settings - Fork 14
/
SmartFox.hx
2262 lines (2008 loc) · 81 KB
/
SmartFox.hx
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
/* ---------------------------------------
*<><><><><>SmartFoxServer 2X<><><><><>
* ---------------------------------------
* Actionscript 3.0 Client API
*
* www.smartfoxserver.com
*(c)2009-2013 gotoAndPlay()
*/
package com.smartfoxserver.v2;
import com.smartfoxserver.v2.entities.managers.IBuddyManager;
import com.smartfoxserver.v2.entities.Room;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.managers.IRoomManager;
import com.smartfoxserver.v2.util.ConnectionMode;
import com.smartfoxserver.v2.bitswarm.BitSwarmClient;
import com.smartfoxserver.v2.bitswarm.BitSwarmEvent;
import com.smartfoxserver.v2.bitswarm.DefaultUDPManager;
import com.smartfoxserver.v2.bitswarm.IMessage;
import com.smartfoxserver.v2.bitswarm.IUDPManager;
import com.smartfoxserver.v2.bitswarm.IoHandler;
import com.smartfoxserver.v2.core.SFSEvent;
import com.smartfoxserver.v2.core.SFSIOHandler;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.managers.IUserManager;
import com.smartfoxserver.v2.entities.managers.SFSBuddyManager;
import com.smartfoxserver.v2.entities.managers.SFSGlobalUserManager;
import com.smartfoxserver.v2.entities.managers.SFSRoomManager;
import com.smartfoxserver.v2.exceptions.SFSCodecError;
import com.smartfoxserver.v2.exceptions.SFSError;
import com.smartfoxserver.v2.exceptions.SFSValidationError;
import com.smartfoxserver.v2.logging.Logger;
import com.smartfoxserver.v2.requests.BaseRequest;
import com.smartfoxserver.v2.requests.HandshakeRequest;
import com.smartfoxserver.v2.requests.IRequest;
import com.smartfoxserver.v2.requests.JoinRoomRequest;
import com.smartfoxserver.v2.requests.ManualDisconnectionRequest;
import com.smartfoxserver.v2.util.ClientDisconnectionReason;
import com.smartfoxserver.v2.util.ConfigData;
import com.smartfoxserver.v2.util.ConfigLoader;
import com.smartfoxserver.v2.util.CryptoInitializer;
import com.smartfoxserver.v2.util.LagMonitor;
import com.smartfoxserver.v2.util.SFSErrorCodes;
import openfl.errors.ArgumentError;
import flash.errors.IllegalOperationError;
import flash.events.EventDispatcher;
import flash.system.Capabilities;
//--------------------------------------
// Connection events
//--------------------------------------
/**
* Dispatched when a connection between the client and a SmartFoxServer 2X instance is attempted.
* This event is fired in response to a call to the<em>connect()</em>method.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CONNECTION
*
* @see #connect()
*/
//[Event(name="connection", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the connection between the client and the SmartFoxServer 2X instance is Interrupted.
* This event is fired in response to a call to the<em>disconnect()</em>method.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CONNECTION_LOST
*
* @see #disconnect()
* @see #event:connectionRetry connectionRetry event
*/
//[Event(name="connectionLost", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the connection between the client and the SmartFoxServer 2X instance is Interrupted abruptly
* while the SmartFoxServer 2X HRC system is available in the Zone.
*
*<p>The HRC system allows a broken connection to be re-established transparently within a certain amount of time, without loosing any of the current
* application state. For example this allows any player to get back to a game without loosing the match because of a sloppy Internet connection.</p>
*
*<p>When this event is dispatched the API enter a "freeze" mode where no new requests can be sent until the reconnection is successfully performed.
* It is highly recommended to handle this event and freeze the application Interface accordingly until the<em>connectionResume</em>event is fired,
* or the reconnection fails and the user is definitely disconnected and the<em>connectionLost</em>event is fired.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CONNECTION_RETRY
*
* @see #event:connectionResume connectionResume event
* @see #event:connectionLost connectionLost event
*/
//[Event(name="connectionRetry", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the connection between the client and the SmartFoxServer 2X instance is re-established after a temporary disconnection,
* while the SmartFoxServer 2X HRC system is available in the Zone.
*
*<p>The HRC system allows a broken connection to be re-established transparently within a certain amount of time, without loosing any of the current
* application state. For example this allows any player to get back to a game without loosing the match because of a sloppy Internet connection.</p>
*
*<p>When this event is dispatched the application Interface should be reverted to the state it had before the disconnection.
* In case the reconnection attempt fails, the<em>connectionLost</em>event is fired.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CONNECTION_RESUME
*
* @see #event:connectionResume connectionRetry event
* @see #event:connectionLost connectionLost event
*/
//[Event(name="connectionResume", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the client cannot establish a socket connection to the server and the<em>useBlueBox</em>parameter is active in the configuration.
*
*<p>The event can be used to notify the user that a second connection attempt is running, using the BlueBox(HTTP tunnelling).</p>
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CONNECTION_ATTEMPT_HTTP
*/
//[Event(name="connectionAttemptHttp", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the result of the UDP handshake is notified.
* This event is fired in response to a call to the<em>initUDP()</em>method.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.UDP_INIT
*
* @see #initUDP()
*/
//[Event(name="udpInit", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the external client configuration file is loaded successfully.
* This event is fired in response to a call to the<em>loadConfig()</em>method,
* but only if the<em>connectOnSuccess</em>argument of the<em>loadConfig()</em>method is set to<code>false</code>;
* otherwise the connection is attempted and the related<em>SFSEvent.CONNECTION</em>event type is fired.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CONFIG_LOAD_SUCCESS
*
* @see #loadConfig()
*/
//[Event(name="configLoadSuccess", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched if an error occurs while loading the external client configuration file.
* This event is fired in response to a call to the<em>loadConfig()</em>method,
* typically when the configuration file is not found or it isn't accessible(no read permissions).
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CONFIG_LOAD_FAILURE
*
* @see #loadConfig()
*/
//[Event(name="configLoadFailure", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched in return to the initialization of an encrypted connection.
* This event is fired in response to a call to the <em>initCrypto()</em> method.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.CRYPTO_INIT
*
* @see #initCrypto()
*/
//[Event(name = "udpInit", type = "com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Login events
//--------------------------------------
/**
* Dispatched when the current user performs a successful login in a server Zone.
* This event is fired in response to the<em>LoginRequest</em>request.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.LOGIN
*
* @see com.smartfoxserver.v2.requests.LoginRequest LoginRequest
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="login", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched if an error occurs while the user login is being performed.
* This event is fired in response to the<em>LoginRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.LOGIN_ERROR
*
* @see com.smartfoxserver.v2.requests.LoginRequest LoginRequest
*/
//[Event(name="loginError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the current user performs logs out of the server Zone.
* This event is fired in response to the<em>LogoutRequest</em>request.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.LOGOUT
*
* @see com.smartfoxserver.v2.requests.LogoutRequest LogoutRequest
*/
//[Event(name="logout", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Room events
//--------------------------------------
/**
* Dispatched when a new Room is created inside the Zone under any of the Room Groups that the client subscribed.
* This event is fired in response to the<em>CreateRoomRequest</em>and<em>CreateSFSGameRequest</em>requests in case the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_ADD
*
* @see com.smartfoxserver.v2.requests.CreateRoomRequest CreateRoomRequest
* @see com.smartfoxserver.v2.requests.game.CreateSFSGameRequest CreateSFSGameRequest
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomAdd", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched if an error occurs while creating a new Room.
* This event is fired in response to the<em>CreateRoomRequest</em>and<em>CreateSFSGameRequest</em>requests in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_CREATION_ERROR
*
* @see com.smartfoxserver.v2.requests.CreateRoomRequest CreateRoomRequest
* @see com.smartfoxserver.v2.requests.game.CreateSFSGameRequest CreateSFSGameRequest
*/
//[Event(name="roomCreationError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a Room belonging to one of the Groups subscribed by the client is removed from the Zone.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_REMOVE
*
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomRemove", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a Room is joined by the current user.
* This event is fired in response to the<em>JoinRoomRequest</em>and<em>QuickJoinGameRequest</em>
* requests in case the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_JOIN
*
* @see com.smartfoxserver.v2.requests.JoinRoomRequest JoinRoomRequest
* @see com.smartfoxserver.v2.requests.game.QuickJoinGameRequest QuickJoinGameRequest
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomJoin", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while the current user is trying to join a Room.
* This event is fired in response to the<em>JoinRoomRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_JOIN_ERROR
*
* @see com.smartfoxserver.v2.requests.JoinRoomRequest JoinRoomRequest
*/
//[Event(name="roomJoinError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when one of the Rooms joined by the current user is entered by another user.
* This event is caused by a<em>JoinRoomRequest</em>request;it might be fired or not depending
* on the Room configuration defined upon its creation(see the<em>RoomSettings.events</em>setting).
*
*<p><b>NOTE</b>:if the Room is of type MMORoom, this event is never fired and it is substituted by the<em>SFSEvent.PROXIMITY_LIST_UPDATE</em>event.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.USER_ENTER_ROOM
*
* @see com.smartfoxserver.v2.requests.JoinRoomRequest JoinRoomRequest
* @see com.smartfoxserver.v2.requests.RoomSettings#events RoomSettings#events
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.Room Room
* @see com.smartfoxserver.v2.entities.MMORoom MMORoom
*/
//[Event(name="userEnterRoom", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when one of the Rooms joined by the current user is left by another user, or by the current user himself.
* This event is caused by a<em>LeaveRoomRequest</em>request;it might be fired or not depending
* on the Room configuration defined upon its creation(see the<em>RoomSettings.events</em>setting).
*
*<p><b>NOTE</b>:if the Room is of type MMORoom, this event is fired when the current user leaves the Room only.
* For the other users leaving the Room it is substituted by the<em>SFSEvent.PROXIMITY_LIST_UPDATE</em>event.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.USER_EXIT_ROOM
*
* @see com.smartfoxserver.v2.requests.LeaveRoomRequest LeaveRoomRequest
* @see com.smartfoxserver.v2.requests.RoomSettings#events RoomSettings#events
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="userExitRoom", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the number of users/players or spectators inside a Room changes.
* This event is caused by a<em>JoinRoomRequest</em>request or a<em>LeaveRoomRequest</em>request.
* The Room must belong to one of the Groups subscribed by the current client;also
* this event might be fired or not depending on the Room configuration defined upon its
* creation(see the<em>RoomSettings.events</em>setting).
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.USER_COUNT_CHANGE
*
* @see com.smartfoxserver.v2.requests.JoinRoomRequest JoinRoomRequest
* @see com.smartfoxserver.v2.requests.LeaveRoomRequest LeaveRoomRequest
* @see com.smartfoxserver.v2.requests.RoomSettings#events RoomSettings#events
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="userCountChange", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a player is turned to a spectator inside a Game Room.
* This event is fired in response to the<em>PlayerToSpectatorRequest</em>>request if the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.PLAYER_TO_SPECTATOR
*
* @see com.smartfoxserver.v2.requests.PlayerToSpectatorRequest PlayerToSpectatorRequest
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="playerToSpectator", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while the current user is being turned from player to spectator in a Game Room.
* This event is fired in response to the<em>PlayerToSpectatorRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.PLAYER_TO_SPECTATOR_ERROR
*
* @see com.smartfoxserver.v2.requests.PlayerToSpectatorRequest PlayerToSpectatorRequest
*/
//[Event(name="playerToSpectatorError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a spectator is turned to a player inside a Game Room.
* This event is fired in response to the<em>SpectatorToPlayerRequest</em>>request if the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.SPECTATOR_TO_PLAYER
*
* @see com.smartfoxserver.v2.requests.SpectatorToPlayerRequest SpectatorToPlayerRequest
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="spectatorToPlayer", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while the current user is being turned from spectator to player in a Game Room.
* This event is fired in response to the<em>SpectatorToPlayerRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.SPECTATOR_TO_PLAYER_ERROR
*
* @see com.smartfoxserver.v2.requests.SpectatorToPlayerRequest SpectatorToPlayerRequest
*/
//[Event(name="spectatorToPlayerError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the name of a Room is changed.
* This event is fired in response to the<em>ChangeRoomNameRequest</em>request if the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_NAME_CHANGE
*
* @see com.smartfoxserver.v2.requests.ChangeRoomNameRequest ChangeRoomNameRequest
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomNameChange", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while attempting to change the name of a Room.
* This event is fired in response to the<em>ChangeRoomNameRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_NAME_CHANGE_ERROR
*
* @see com.smartfoxserver.v2.requests.ChangeRoomNameRequest ChangeRoomNameRequest
*/
//[Event(name="roomNameChangeError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the password of a Room is set, changed or removed.
* This event is fired in response to the<em>ChangeRoomPasswordStateRequest</em>request if the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_PASSWORD_STATE_CHANGE
*
* @see com.smartfoxserver.v2.requests.ChangeRoomPasswordStateRequest ChangeRoomPasswordStateRequest
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomPasswordStateChange", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while attempting to set, change or remove the password of a Room.
* This event is fired in response to the<em>ChangeRoomPasswordStateRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR
*
* @see com.smartfoxserver.v2.requests.ChangeRoomPasswordStateRequest ChangeRoomPasswordStateRequest
*/
//[Event(name="roomPasswordStateChangeError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the capacity of a Room is changed.
* This event is fired in response to the<em>ChangeRoomCapacityRequest</em>request if the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_CAPACITY_CHANGE
*
* @see com.smartfoxserver.v2.requests.ChangeRoomCapacityRequest ChangeRoomCapacityRequest
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomCapacityChange", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while attempting to change the capacity of a Room.
* This event is fired in response to the<em>ChangeRoomCapacityRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR
*
* @see com.smartfoxserver.v2.requests.ChangeRoomCapacityRequest ChangeRoomCapacityRequest
*/
//[Event(name="roomCapacityChangeError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when one more users or one or more MMOItem objects enter/leave the current user's Area of Interest in MMORooms.
* This event is fired after an MMORoom is joined and the<em>SetUserPositionRequest</em>request is sent at least one time.
*
*<p><b>NOTE</b>:this event substitutes the default<em>SFSEvent.USER_ENTER_ROOM</em>and<em>SFSEvent.USER_EXIT_ROOM</em>events available in regular Rooms.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.PROXIMITY_LIST_UPDATE
*
* @see com.smartfoxserver.v2.requests.mmo.SetUserPositionRequest SetUserPositionRequest
* @see com.smartfoxserver.v2.entities.MMORoom MMORoom
* @see com.smartfoxserver.v2.entities.MMOItem MMOItem
*/
//[Event(name="proximityListUpdate", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Message events
//--------------------------------------
/**
* Dispatched when a public message is received by the current user.
* This event is caused by a<em>PublicMessageRequest</em>request sent by any user in the target Room, including the current user himself.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.PUBLIC_MESSAGE
*
* @see com.smartfoxserver.v2.requests.PublicMessageRequest PublicMessageRequest
* @see com.smartfoxserver.v2.entities.Room Room
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="publicMessage", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a private message is received by the current user.
* This event is caused by a<em>PrivateMessageRequest</em>request sent by any user in the Zone.
*
*<p><b>NOTE</b>:the same event is fired by the sender's client too, so that the user is aware that the message was delivered successfully to the recipient,
* and it can be displayed in the private chat area keeping the correct message ordering. In this case there is no default way to know who the message was originally sent to.
* As this information can be useful in scenarios where the sender is chatting privately with more than one user at the same time in separate windows or tabs
*(and we need to write his own message in the proper one), the<em>data</em>parameter can be used to store, for example, the id of the recipient user.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.PRIVATE_MESSAGE
*
* @see com.smartfoxserver.v2.requests.PrivateMessageRequest PrivateMessageRequest
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="privateMessage", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an object containing custom data is received by the current user.
* This event is caused by an<em>ObjectMessageRequest</em>request sent by any user in the target Room.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.OBJECT_MESSAGE
*
* @see com.smartfoxserver.v2.requests.ObjectMessageRequest DynamicMessageRequest
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="objectMessage", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the current user receives a message from a moderator user.
* This event can be caused by either the<em>ModeratorMessageRequest</em>,<em>KickUserRequest</em>or
*<em>BanUserRequest</em>requests sent by a user with at least moderation privileges.
* Also, this event can be caused by a kick/ban action performed through the SmartFoxServer 2X Administration Tool.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.MODERATOR_MESSAGE
*
* @see com.smartfoxserver.v2.requests.ModeratorMessageRequest ModeratorMessageRequest
* @see com.smartfoxserver.v2.requests.KickUserRequest KickUserRequest
* @see com.smartfoxserver.v2.requests.BanUserRequest BanUserRequest
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="moderatorMessage", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the current user receives a message from an administrator user.
* This event is caused by the<em>AdminMessageRequest</em>request sent by a user with administration privileges.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ADMIN_MESSAGE
*
* @see com.smartfoxserver.v2.requests.AdminMessageRequest AdminMessageRequest
* @see com.smartfoxserver.v2.entities.User User
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="adminMessage", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when data coming from a server-side Extension is received by the current user.
* Data is usually sent by the server to one or more clients in response to an<em>ExtensionRequest</em>request, but not necessarily.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.EXTENSION_RESPONSE
*
* @see com.smartfoxserver.v2.requests.ExtensionRequest ExtensionRequest
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="extensionResponse", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Variables events
//--------------------------------------
/**
* Dispatched when a Room Variable is updated.
* This event is caused by the<em>SetRoomVariablesRequest</em>request. The request could have been sent by a user in the same Room of the current user or,
* in case of a global Room Variable, by a user in a Room belonging to one of the Groups subscribed by the current client.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_VARIABLES_UPDATE
*
* @see com.smartfoxserver.v2.requests.SetRoomVariablesRequest SetRoomVariablesRequest
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomVariablesUpdate", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a User Variable is updated.
* This event is caused by the<em>SetUserVariablesRequest</em>request sent by a user in one of the Rooms joined by the current user.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.USER_VARIABLES_UPDATE
*
* @see com.smartfoxserver.v2.requests.SetUserVariablesRequest SetUserVariablesRequest
* @see com.smartfoxserver.v2.entities.User User
*/
//[Event(name="userVariablesUpdate", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an MMOItem Variable is updated in an MMORoom.
* This event is caused by an MMOItem Variable being set, updated or deleted in a server side Extension, and it is received only if the current user
* has the related MMOItem in his Area of Interest.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.MMOITEM_VARIABLES_UPDATE
*
* @see com.smartfoxserver.v2.entities.MMORoom MMORoom
* @see com.smartfoxserver.v2.entities.variables.MMOItemVariable MMOItemVariable
* @see com.smartfoxserver.v2.entities.MMOItem MMOItem
*/
//[Event(name="mmoItemVariablesUpdate", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Group subscription events
//--------------------------------------
/**
* Dispatched when a Group is subscribed by the current user.
* This event is fired in response to the<em>SubscribeRoomGroupRequest</em>>request if the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_SUBSCRIBE
*
* @see com.smartfoxserver.v2.requests.SubscribeRoomGroupRequest SubscribeRoomGroupRequest
* @see com.smartfoxserver.v2.entities.Room Room
*/
//[Event(name="roomGroupSubscribe", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while a Room Group is being subscribed.
* This event is fired in response to the<em>SubscribeRoomGroupRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR
*
* @see com.smartfoxserver.v2.requests.SubscribeRoomGroupRequest SubscribeRoomGroupRequest
*/
//[Event(name="roomGroupSubscribeError", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a Group is unsubscribed by the current user.
* This event is fired in response to the<em>UnsubscribeRoomGroupRequest</em>>request if the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_UNSUBSCRIBE
*
* @see com.smartfoxserver.v2.requests.UnsubscribeRoomGroupRequest UnsubscribeRoomGroupRequest
*/
//[Event(name="roomGroupUnsubscribe", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while a Room Group is being unsubscribed.
* This event is fired in response to the<em>UnsubscribeRoomGroupRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR
*
* @see com.smartfoxserver.v2.requests.UnsubscribeRoomGroupRequest UnsubscribeRoomGroupRequest
*/
//[Event(name="roomGroupUnsubscribeError", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Find events
//--------------------------------------
/**
* Dispatched when a Rooms search is completed.
* This event is fired in response to the<em>FindRoomsRequest</em>request to return the search result.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.ROOM_FIND_RESULT
*
* @see com.smartfoxserver.v2.requests.FindRoomsRequest FindRoomsRequest
*/
//[Event(name="roomFindResult", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a users search is completed.
* This event is fired in response to the<em>FindUsersRequest</em>request to return the search result.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.USER_FIND_RESULT
*
* @see com.smartfoxserver.v2.requests.FindUsersRequest FindUsersRequest
*/
//[Event(name="userFindResult", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Invitation events
//--------------------------------------
/**
* Dispatched when the current user receives an invitation from another user.
* This event is caused by the<em>InviteUsersRequest</em>request;the user is supposed to reply
* using the<em>InvitationReplyRequest</em>request.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.INVITATION
*
* @see com.smartfoxserver.v2.requests.game.InviteUsersRequest InviteUsersRequest
* @see com.smartfoxserver.v2.requests.game.InvitationReplyRequest InvitationReplyRequest
* @see com.smartfoxserver.v2.entities.invitation.Invitation Invitation
*/
//[Event(name="invitation", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when the current user receives a reply to an invitation he sent previously.
* This event is caused by the<em>InvitationReplyRequest</em>request sent by the invitee.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.INVITATION_REPLY
*
* @see com.smartfoxserver.v2.requests.game.InvitationReplyRequest InvitationReplyRequest
* @see com.smartfoxserver.v2.entities.invitation.InvitationReply InvitationReply
* @see com.smartfoxserver.v2.entities.data.SFSObject SFSObject
*/
//[Event(name="invitationReply", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when an error occurs while the current user is sending a reply to an invitation he received.
* This event is fired in response to the<em>InvitationReplyRequest</em>request in case the operation failed.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.INVITATION_REPLY_ERROR
*
* @see com.smartfoxserver.v2.requests.game.InvitationReplyRequest InvitationReplyRequest
*/
//[Event(name="invitationReplyError", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Buddy events
//--------------------------------------
/**
* Dispatched if the Buddy List system is successfully initialized.
* This event is fired in response to the<em>InitBuddyListRequest</em>request in case the operation is executed successfully.
*
*<p>After the Buddy List system initialization, the user returns to his previous custom state(if any - see<em>IBuddyManager.myState</em>property).
* His online/offline state, his nickname and his persistent Buddy Variables are all loaded and broadcast in the system.
* In particular, the online state(see<em>IBuddyManager.myOnlineState</em>property)determines if the user will appear online or not to other users who have him in their buddies list.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_LIST_INIT
*
* @see com.smartfoxserver.v2.requests.buddylist.InitBuddyListRequest InitBuddyListRequest
* @see com.smartfoxserver.v2.entities.managers.IBuddyManager IBuddyManager
* @see com.smartfoxserver.v2.entities.Buddy Buddy
* @see com.smartfoxserver.v2.entities.variables.BuddyVariable BuddyVariable
*/
//[Event(name="buddyListInit", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
/**
* Dispatched when a buddy is added successfully to the current user's buddies list.
* This event is fired in response to the<em>AddBuddyRequest</em>request in case the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_ADD
*
* @see com.smartfoxserver.v2.requests.buddylist.AddBuddyRequest AddBuddyRequest
* @see com.smartfoxserver.v2.entities.Buddy Buddy
*/
//[Event(name="buddyAdd", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
/**
* Dispatched when a buddy is blocked or unblocked successfully by the current user.
* This event is fired in response to the<em>BlockBuddyRequest</em>request in case the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_BLOCK
*
* @see com.smartfoxserver.v2.requests.buddylist.BlockBuddyRequest BlockBuddyRequest
* @see com.smartfoxserver.v2.entities.Buddy Buddy
*/
//[Event(name="buddyBlock", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
/**
* Dispatched when a buddy is removed successfully from the current user's buddies list.
* This event is fired in response to the<em>RemoveBuddyRequest</em>request in case the operation is executed successfully.
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_REMOVE
*
* @see com.smartfoxserver.v2.requests.buddylist.RemoveBuddyRequest RemoveBuddyRequest
* @see com.smartfoxserver.v2.entities.Buddy Buddy
*/
//[Event(name="buddyRemove", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
/**
* Dispatched if an error occurs while executing a request related to the Buddy List system.
* For example, this event is fired in response to the<em>AddBuddyRequest</em>request, the<em>BlockBuddyRequest</em>, etc.
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_ERROR
*/
//[Event(name="buddyError", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
/**
* Dispatched when a message from a buddy is received by the current user.
* This event is fired in response to the<em>BuddyMessageRequest</em>request.
*
*<p><b>NOTE</b>:the same event is fired by the sender's client too, so that the user is aware that the message was delivered successfully to the recipient,
* and it can be displayed in the chat area keeping the correct message ordering. As in this case the value of the<em>buddy</em>parameter is<code>null</code>
*(because, being the sender, the user is not buddy to himself of course), there is no default way to know who the message was originally sent to.
* As this information can be useful in scenarios where the sender is chatting with more than one buddy at the same time in separate windows or tabs
*(and we need to write his own message in the proper one), the<em>data</em>parameter can be used to store, for example, the id of the recipient buddy.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_MESSAGE
*
* @see com.smartfoxserver.v2.requests.buddylist.BuddyMessageRequest BuddyMessageRequest
* @see com.smartfoxserver.v2.entities.Buddy Buddy
*/
//[Event(name="buddyMessage", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
/**
* Dispatched when a buddy in the current user's buddies list changes his online state in the Buddy List system.
* This event is fired in response to the<em>GoOnlineRequest</em>request.
*
*<p><b>NOTE</b>:this event is dispatched to those who have the user as a buddy, but also to the user himself.
* As in this case the value of the<em>buddy</em>parameter is<code>null</code>(because the user is not buddy to himself of course),
* the<em>isItMe</em>parameter should be used to check if the current user is the one who changed his own online state.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_ONLINE_STATE_UPDATE
*
* @see com.smartfoxserver.v2.requests.buddylist.GoOnlineRequest GoOnlineRequest
* @see com.smartfoxserver.v2.entities.Buddy Buddy
*/
//[Event(name="buddyOnlineStateChange", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
/**
* Dispatched when a buddy in the current user's buddies list updates one or more Buddy Variables.
* This event is fired in response to the<em>SetBuddyVariablesRequest</em>request.
*
*<p><b>NOTE</b>:this event is dispatched to those who have the user as a buddy, but also to the user himself.
* As in this case the value of the<em>buddy</em>parameter is<code>null</code>(because the user is not buddy to himself of course),
* the<em>isItMe</em>parameter should be used to check if the current user is the one who updated his own Buddy Variables.</p>
*
* @eventType com.smartfoxserver.v2.core.SFSBuddyEvent.BUDDY_VARIABLES_UPDATE
*
* @see com.smartfoxserver.v2.requests.buddylist.SetBuddyVariablesRequest SetBuddyVariablesRequest
* @see com.smartfoxserver.v2.entities.variables.BuddyVariable BuddyVariable
* @see com.smartfoxserver.v2.entities.Buddy Buddy
*/
//[Event(name="buddyVariablesUpdate", type="com.smartfoxserver.v2.core.SFSBuddyEvent")]
//--------------------------------------
// Other events
//--------------------------------------
/**
* Dispatched when a new lag value measurement is available.
* This event is fired when the automatic lag monitoring is turned on by passing<code>true</code>to the<em>enableLagMonitor()</em>method.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.PING_PONG
*
* @see #enableLagMonitor()
*/
//[Event(name="pingPong", type="com.smartfoxserver.v2.core.SFSEvent")]
/**
* Dispatched when a low level socket error is detected, for example bad/inconsistent data.
*
* @eventType com.smartfoxserver.v2.core.SFSEvent.SOCKET_ERROR
*/
//[Event(name="socketError", type="com.smartfoxserver.v2.core.SFSEvent")]
//--------------------------------------
// Class
//--------------------------------------
/**
*<em>SmartFox</em>is the main class of the SmartFoxServer 2X API.
* It is responsible for connecting the client to a SmartFoxServer instance and for dispatching all asynchronous events.
* Developers always Interact with SmartFoxServer through this class.
*
*<p><b>NOTE</b>:in the provided examples,<code>sfs</code>always indicates a<em>SmartFox</em>instance.</p>
*
* @see http://www.smartfoxserver.com
*
* @version 1.2.x
*
* @author The gotoAndPlay()Team
* http://www.smartfoxserver.com
* http://www.gotoandplay.it
*/
class SmartFox extends EventDispatcher
{
private static inline var DEFAULT_HTTP_PORT:Int = 8080;
private static inline var CLIENT_TYPE_SEPARATOR:String = ":";
// Current version
private var _majVersion:Int = 1;
private var _minVersion:Int = 6;
private var _subVersion:Int = 0;
// The socket engine
private var _bitSwarm:BitSwarmClient;
private var _lagMonitor:LagMonitor;
// If true the client will fall back to BlueBox if no socket connection is available
private var _useBlueBox:Bool = true;
//https WebSocket protocol (Adobe AIR Target may does not support WSS protocol)
public var useWSS:Bool = true;
// If true the client is connected
private var _isConnected:Bool = false;
// If true the client is in the middle of a join transaction
private var _isJoining:Bool = false;
// References the client's User object
private var _mySelf:User;
// A unique session token, sent by the server during the handshake
private var _sessionToken:String;
// Last joined room
private var _lastJoinedRoom:Room;
// The logger
private var _log:Logger;
// API initialization flag
private var _inited:Bool = false;
// Protocol debug flag
private var _debug:Bool = false;
// Connection attempt flag
private var _isConnecting:Bool = false;
// The global user manager
private var _userManager:IUserManager;
// The global room manager
private var _roomManager:IRoomManager;
// The global buddy manager
private var _buddyManager:IBuddyManager;
private var _config:ConfigData;
// The name of the currently joined Zone
private var _currentZone:String;
// When true ->starts the connection right after successful config loading
private var _autoConnectOnConfig:Bool = false;
// Last ip address used for connection, used when falling back to BlueBox
private var _lastIpAddress:String;
// Client details passed to setClientDetails method
private var _clientDetails:String =
#if flash
"Flash"
#elseif neko
"Neko"
#elseif linux
"Linux"
#elseif windows
"Windows"
#elseif html5
"JavaScript"
#else
"Unknown"
#end
;
/**
* Creates a new<em>SmartFox</em>instance.
*
* @param debug If<code>true</code>, the SmartFoxServer API debug messages are logged.
*
* @example The following example instantiates the<em>SmartFox</em>class while enabling the debug messages:
*<listing version="3.0">
*
* var sfs:SmartFox=new SmartFox(true);
*</listing>
*
* @see #debug
*/
public function new(debug:Bool=false)
{
super();
_log = @:privateAccess new Logger();
_log.enableEventDispatching = true;
_debug = debug;
initialize();
}
// This is done ONCE in the whole life cycle
private function initialize():Void
{
if(_inited)
return;
_bitSwarm = new BitSwarmClient(this);
_bitSwarm.ioHandler = new SFSIOHandler(_bitSwarm);
_bitSwarm.init();
_bitSwarm.addEventListener(BitSwarmEvent.CONNECT, onSocketConnect);
_bitSwarm.addEventListener(BitSwarmEvent.DISCONNECT, onSocketClose);
_bitSwarm.addEventListener(BitSwarmEvent.RECONNECTION_TRY, onSocketReconnectionTry);
_bitSwarm.addEventListener(BitSwarmEvent.IO_ERROR, onSocketIOError);
_bitSwarm.addEventListener(BitSwarmEvent.SECURITY_ERROR, onSocketSecurityError);
_bitSwarm.addEventListener(BitSwarmEvent.DATA_ERROR, onSocketDataError);
addEventListener(SFSEvent.HANDSHAKE, handleHandShake);
addEventListener(SFSEvent.LOGIN, handleLogin);
_inited = true;
reset();
}
private function reset():Void
{
_userManager = new SFSGlobalUserManager(this);
_roomManager = new SFSRoomManager(this);
_buddyManager = new SFSBuddyManager(this);
// Remove previous lag monitor, if any.
if(_lagMonitor !=null)
_lagMonitor.destroy();
_isConnected = false;
_isJoining = false;
_currentZone = null;
_lastJoinedRoom = null;
_sessionToken = null;
_mySelf = null;
}
/*
* addController(controller:BaseController):Void
* allows developers to add new custom, client side controllers to talk to their respective server side controllers
*/
/** @private */
public function enableFullPacketDump(b:Bool):Void
{
cast(_bitSwarm.ioHandler,SFSIOHandler).enableFullPacketDump(b);
}
/**
* Allows to specify custom client details that will be used to gather statistics about the client platform via the AdminTool's Analytics Module.
* By default the generic "Flash" label is used as platform, without specifying the version.
*
*<p><b>NOTE</b>:this method must be called before the connection is started. The length of the two strings combined must be less than 512 characters.</p>
*
* @param platformId An identification string for the client runtime platform:for example "Flash PlugIn" or "iOS".
* @param version An additional string to specify the version of the runtime platform:for example "2.0.0".
*/
public function setClientDetails(platformId:String, version:String):Void
{
if(_isConnected)
{
logger.warn("SetClientDetails must be called before the connection is started");
return;
}
_clientDetails = (platformId != null ? StringTools.replace(platformId, CLIENT_TYPE_SEPARATOR, " "):"");
_clientDetails +=CLIENT_TYPE_SEPARATOR;
_clientDetails += (version != null ? StringTools.replace(version, CLIENT_TYPE_SEPARATOR, " "):"");
}
/**
* Enables the automatic realtime monitoring of the lag between the client and the server(round robin).
* When turned on, the<em>SFSEvent.PING_PONG</em>event type is dispatched continuously, providing the average of the last ten measured lag values.