From 242c96efd7f8d1e7e60622b4fb70c8ef45ed994b Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 2 Oct 2015 15:03:10 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/WebSocketFrame.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/WebSocketFrame.cs b/websocket-sharp/WebSocketFrame.cs index 2fc58798..9d31c2d2 100644 --- a/websocket-sharp/WebSocketFrame.cs +++ b/websocket-sharp/WebSocketFrame.cs @@ -605,15 +605,16 @@ Extended Payload Length: {7} CloseStatusCode.TooBig, "The length of 'Payload Data' of a frame is greater than the allowable max length."); + var llen = (long) len; var bytes = frame._payloadLength < 127 ? stream.ReadBytes ((int) len) - : stream.ReadBytes ((long) len, 1024); + : stream.ReadBytes (llen, 1024); - if (bytes.LongLength != (long) len) + 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._payloadData = new PayloadData (bytes, llen); return frame; } @@ -637,12 +638,13 @@ Extended Payload Length: {7} CloseStatusCode.TooBig, "The length of 'Payload Data' of a frame is greater than the allowable max length."); + var llen = (long) len; Action compl = bytes => { - if (bytes.LongLength != (long) len) + 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._payloadData = new PayloadData (bytes, llen); completed (frame); }; @@ -651,7 +653,7 @@ Extended Payload Length: {7} return; } - stream.ReadBytesAsync ((long) len, 1024, compl, error); + stream.ReadBytesAsync (llen, 1024, compl, error); } #endregion