File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed
src/com/smartfoxserver/v2/bitswarm/wsocket Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,15 @@ class WSClient extends EventDispatcher
51
51
throw " WebSocket session is already connected" ;
52
52
}
53
53
_useSSL = useSSL ;
54
+
55
+ if (ws != null )
56
+ {
57
+ ws .onopen = function () {};
58
+ ws .onmessageBytes = function (bytes : Bytes ) {};
59
+ ws .onclose = function (? e : Dynamic ) {};
60
+ ws .onerror = function (error : String ) {};
61
+ }
62
+
54
63
ws = WebSocket .create (protocol + url + " :" + port + " /BlueBox/websocket" , null , _debug );
55
64
ws .onopen = function () {
56
65
_connected = true ;
@@ -64,7 +73,8 @@ class WSClient extends EventDispatcher
64
73
}));
65
74
};
66
75
ws .onclose = function (? e : Dynamic ) {
67
- handleConnectionLost ();
76
+ _connected = false ;
77
+ dispatchEvent (new WSEvent (WSEvent .CLOSED , {}));
68
78
};
69
79
ws .onerror = function (error : String ) {
70
80
handleIOError (error );
@@ -110,20 +120,9 @@ class WSClient extends EventDispatcher
110
120
111
121
public function close () : Void
112
122
{
113
- handleConnectionLost (false );
114
- }
115
-
116
- private function handleConnectionLost (fireEvent : Bool = true ): Void
117
- {
118
- if (_connected )
119
- {
120
- _connected = false ;
121
- ws .close ();
122
-
123
- // Fire event to Bitswarm client
124
- if (fireEvent )
125
- dispatchEvent (new WSEvent (WSEvent .CLOSED , { }));
126
- }
123
+ ws .onclose = function (? e : Dynamic ) {};
124
+ _connected = false ;
125
+ ws .close ();
127
126
}
128
127
129
128
private function handleIOError (error : String ): Void
You can’t perform that action at this time.
0 commit comments