[Modify] Polish it
This commit is contained in:
parent
011fc19269
commit
d2bb267306
@ -631,36 +631,21 @@ Extended Payload Length: {7}
|
|||||||
CloseStatusCode.TooBig,
|
CloseStatusCode.TooBig,
|
||||||
"The length of 'Payload Data' of a frame is greater than the allowable max length.");
|
"The length of 'Payload Data' of a frame is greater than the allowable max length.");
|
||||||
|
|
||||||
|
Action<byte[]> compl = bytes => {
|
||||||
|
if (bytes.LongLength != (long) len)
|
||||||
|
throw new WebSocketException (
|
||||||
|
"The 'Payload Data' of a frame cannot be read from the data source.");
|
||||||
|
|
||||||
|
frame._payloadData = new PayloadData (bytes, frame.IsMasked);
|
||||||
|
completed (frame);
|
||||||
|
};
|
||||||
|
|
||||||
if (frame._payloadLength < 127) {
|
if (frame._payloadLength < 127) {
|
||||||
var ilen = (int) len;
|
stream.ReadBytesAsync ((int) len, compl, error);
|
||||||
stream.ReadBytesAsync (
|
|
||||||
ilen,
|
|
||||||
bytes => {
|
|
||||||
if (bytes.Length != ilen)
|
|
||||||
throw new WebSocketException (
|
|
||||||
"The 'Payload Data' of a frame cannot be read from the data source.");
|
|
||||||
|
|
||||||
frame._payloadData = new PayloadData (bytes, frame.IsMasked);
|
|
||||||
completed (frame);
|
|
||||||
},
|
|
||||||
error);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var llen = (long) len;
|
stream.ReadBytesAsync ((long) len, 1024, compl, error);
|
||||||
stream.ReadBytesAsync (
|
|
||||||
llen,
|
|
||||||
1024,
|
|
||||||
bytes => {
|
|
||||||
if (bytes.LongLength != llen)
|
|
||||||
throw new WebSocketException (
|
|
||||||
"The 'Payload Data' of a frame cannot be read from the data source.");
|
|
||||||
|
|
||||||
frame._payloadData = new PayloadData (bytes, frame.IsMasked);
|
|
||||||
completed (frame);
|
|
||||||
},
|
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user