|
|
|
|
@ -36,9 +36,13 @@ namespace WebSocketSharp
|
|
|
|
|
{
|
|
|
|
|
#region Private Fields
|
|
|
|
|
|
|
|
|
|
private ushort _code;
|
|
|
|
|
private bool _codeSet;
|
|
|
|
|
private byte[] _data;
|
|
|
|
|
private long _extDataLength;
|
|
|
|
|
private long _length;
|
|
|
|
|
private string _reason;
|
|
|
|
|
private bool _reasonSet;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
@ -80,7 +84,11 @@ namespace WebSocketSharp
|
|
|
|
|
|
|
|
|
|
internal PayloadData ()
|
|
|
|
|
{
|
|
|
|
|
_code = 1005;
|
|
|
|
|
_data = WebSocket.EmptyBytes;
|
|
|
|
|
|
|
|
|
|
_codeSet = true;
|
|
|
|
|
_reasonSet = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal PayloadData (byte[] data)
|
|
|
|
|
@ -94,10 +102,36 @@ namespace WebSocketSharp
|
|
|
|
|
_length = length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal PayloadData (ushort code, string reason)
|
|
|
|
|
{
|
|
|
|
|
_code = code;
|
|
|
|
|
_reason = reason;
|
|
|
|
|
|
|
|
|
|
_data = code.Append (reason);
|
|
|
|
|
_length = _data.LongLength;
|
|
|
|
|
|
|
|
|
|
_codeSet = true;
|
|
|
|
|
_reasonSet = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Internal Properties
|
|
|
|
|
|
|
|
|
|
internal ushort Code {
|
|
|
|
|
get {
|
|
|
|
|
if (!_codeSet) {
|
|
|
|
|
_code = _length > 1
|
|
|
|
|
? _data.SubArray (0, 2).ToUInt16 (ByteOrder.Big)
|
|
|
|
|
: (ushort) 1005;
|
|
|
|
|
|
|
|
|
|
_codeSet = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal long ExtensionDataLength {
|
|
|
|
|
get {
|
|
|
|
|
return _extDataLength;
|
|
|
|
|
@ -114,6 +148,20 @@ namespace WebSocketSharp
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal string Reason {
|
|
|
|
|
get {
|
|
|
|
|
if (!_reasonSet) {
|
|
|
|
|
_reason = _length > 2
|
|
|
|
|
? _data.SubArray (2, _length - 2).UTF8Decode ()
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
_reasonSet = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _reason;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Public Properties
|
|
|
|
|
|