Refactored WebSocket.cs
This commit is contained in:
parent
673d7225bd
commit
2a8a9ca061
@ -481,7 +481,7 @@ namespace WebSocketSharp
|
|||||||
: code == CloseStatusCode.INCONSISTENT_DATA
|
: code == CloseStatusCode.INCONSISTENT_DATA
|
||||||
? "An inconsistent data has been received."
|
? "An inconsistent data has been received."
|
||||||
: code == CloseStatusCode.POLICY_VIOLATION
|
: code == CloseStatusCode.POLICY_VIOLATION
|
||||||
? "A policy violation data has been received."
|
? "A policy violation has occurred."
|
||||||
: code == CloseStatusCode.TOO_BIG
|
: code == CloseStatusCode.TOO_BIG
|
||||||
? "A too big data has been received."
|
? "A too big data has been received."
|
||||||
: code == CloseStatusCode.IGNORE_EXTENSION
|
: code == CloseStatusCode.IGNORE_EXTENSION
|
||||||
|
@ -810,38 +810,52 @@ namespace WebSocketSharp
|
|||||||
|
|
||||||
private bool concatenateFragmentsInto (Stream dest)
|
private bool concatenateFragmentsInto (Stream dest)
|
||||||
{
|
{
|
||||||
var frame = _stream.ReadFrame ();
|
while (true) {
|
||||||
|
var frame = _stream.ReadFrame ();
|
||||||
|
|
||||||
// MORE & CONT
|
if (frame.IsFinal) {
|
||||||
if (!frame.IsFinal && frame.IsContinuation) {
|
// FINAL
|
||||||
dest.WriteBytes (frame.PayloadData.ApplicationData);
|
|
||||||
return concatenateFragmentsInto (dest);
|
// CONT
|
||||||
|
if (frame.IsContinuation) {
|
||||||
|
dest.WriteBytes (frame.PayloadData.ApplicationData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PING
|
||||||
|
if (frame.IsPing) {
|
||||||
|
acceptPingFrame (frame);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PONG
|
||||||
|
if (frame.IsPong) {
|
||||||
|
acceptPongFrame (frame);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CLOSE
|
||||||
|
if (frame.IsClose)
|
||||||
|
return acceptCloseFrame (frame);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// MORE
|
||||||
|
|
||||||
|
// CONT
|
||||||
|
if (frame.IsContinuation) {
|
||||||
|
dest.WriteBytes (frame.PayloadData.ApplicationData);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ?
|
||||||
|
return acceptUnsupportedFrame (
|
||||||
|
frame,
|
||||||
|
CloseStatusCode.INCORRECT_DATA,
|
||||||
|
"An incorrect data has been received while receiving fragmented data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FINAL & CONT
|
return true;
|
||||||
if (frame.IsFinal && frame.IsContinuation) {
|
|
||||||
dest.WriteBytes (frame.PayloadData.ApplicationData);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FINAL & PING
|
|
||||||
if (frame.IsFinal && frame.IsPing) {
|
|
||||||
acceptPingFrame (frame);
|
|
||||||
return concatenateFragmentsInto (dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FINAL & PONG
|
|
||||||
if (frame.IsFinal && frame.IsPong) {
|
|
||||||
acceptPongFrame (frame);
|
|
||||||
return concatenateFragmentsInto (dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FINAL & CLOSE
|
|
||||||
if (frame.IsFinal && frame.IsClose)
|
|
||||||
return acceptCloseFrame (frame);
|
|
||||||
|
|
||||||
// ?
|
|
||||||
return acceptUnsupportedFrame (frame, CloseStatusCode.INCORRECT_DATA, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool connect ()
|
private bool connect ()
|
||||||
|
Loading…
Reference in New Issue
Block a user