/
/
/
/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
收到消息
c._ws.onMessage(function(a) {
c.OnEventReceiveData(a.data)
});
/
/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
OnEventReceiveData
OnEventReceiveData: function(a) {
if
(this._socketState
=
=
SOCKET_STATE_CONNECTED && a) {
var b
=
new MsgHeader(!
1
);
b.
from
(a);
switch (this.UnEscapeMessage(b)) {
case UNESCAPEMSG_ERROR:
this.OnEventClose(
0
);
break
;
case UNESCAPEMSG_IGNORE:
break
;
default:
b.wMessageID
=
=
MSG_KEEPALIVE ? (this._bSentKeepAlive
=
!
1
, a
=
MsgKeepAliveReply.
from
(a).dwTimeStamp, this._dwPing
=
DateEx.getCurDateMilliSeconds()
-
a) : this._messageProcessor && this._messageProcessor.OnProcessMessage(b)
}
}
},
/
/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
UnEscapeMessage
UnEscapeMessage: function(a) {
var b
=
a.byFlag,
c
=
a.getOriginBuffer(),
d
=
c.byteLength
-
a.byHeaderOffset;
if
(d && b & MSG_HEADER_FLAG_COMPRESS && !isNative()) {
b
=
void
0
;
d
=
new Uint8Array(c, a.byHeaderOffset, d);
try
{
b
=
(new Zlib.Inflate(d)).decompress()
} catch (e) {
b
=
new Uint8Array(c,
0
, c.byteLength), log(this.bin2hex(b)), log(this.bin2hex(d)), b
=
void
0
, log(
"\u6570\u636e\u89e3\u538b\u5931\u8d25,err:"
, e.message)
}
if
(b &&
b instanceof Uint8Array) {
var c
=
new Uint8Array(c,
0
, a.byHeaderOffset),
d
=
a.byHeaderOffset
+
b.length,
f
=
new Uint8Array(d);
f.
set
(c,
0
);
f.
set
(b, a.byHeaderOffset);
a.
from
(f.
buffer
);
a.wLen
=
d
}
else
return
UNESCAPEMSG_ERROR
}
return
UNESCAPEMSG_OK
},
/
/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
加密函数
EscapeMessage: function(a) {
var b
=
a.byFlag;
if
(!(b & MSG_HEADER_FLAG_FILLED)) {
b & MSG_HEADER_FLAG_OFFSET || (a.byHeaderOffset
=
8
);
var c
=
a.getPosition()
-
a.byHeaderOffset;
if
(c) {
var d
=
new Uint8Array(a.getOriginBuffer(), a.byHeaderOffset, c);
if
(b & MSG_HEADER_FLAG_COMPRESS) {
var e
=
void
0
;
try
{
e
=
Zlib.Deflate.compress(d)
} catch (f) {
e
=
void
0
, log(
"\u6d88\u606f\u6570\u636e\u538b\u7f29\u51fa\u9519, err:"
, f.message)
}
if
(e && e instanceof Uint8Array && e.length < c) {
for
(var g
=
0
; g < e.length; g
+
+
) d[g]
=
e[g];
c
=
e.length;
a.wLen
=
e.length
+
a.byHeaderOffset;
a.updatePosition(a.wLen)
}
else
a.byFlag ^
=
MSG_HEADER_FLAG_COMPRESS
}
b & MSG_HEADER_FLAG_ENCODE && (a.byFlag ^
=
MSG_HEADER_FLAG_ENCODE);
if
(b & MSG_HEADER_FLAG_MASK) {
b
=
a.byMask;
b
=
Math.floor(
256
*
Math.random());
for
(g
=
0
; g < c; g
+
+
) d[g] ^
=
b, b ^
=
g
%
256
;
a.byMask
=
b
}
}
a.byFlag |
=
MSG_HEADER_FLAG_FILLED
}
}