diff --git a/Example/bin/Debug_Ubuntu/example.exe b/Example/bin/Debug_Ubuntu/example.exe index 5d0e35a2..a0f9a695 100755 Binary files a/Example/bin/Debug_Ubuntu/example.exe and b/Example/bin/Debug_Ubuntu/example.exe differ diff --git a/Example/bin/Debug_Ubuntu/websocket-sharp.dll b/Example/bin/Debug_Ubuntu/websocket-sharp.dll index e7cc86f5..06cb0344 100755 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe b/Example1/bin/Debug_Ubuntu/example1.exe index 8660283f..1a461ee5 100755 Binary files a/Example1/bin/Debug_Ubuntu/example1.exe and b/Example1/bin/Debug_Ubuntu/example1.exe differ diff --git a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll index e7cc86f5..06cb0344 100755 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example2/bin/Debug_Ubuntu/example2.exe b/Example2/bin/Debug_Ubuntu/example2.exe index 440909b6..1a87d99b 100755 Binary files a/Example2/bin/Debug_Ubuntu/example2.exe and b/Example2/bin/Debug_Ubuntu/example2.exe differ diff --git a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll index e7cc86f5..06cb0344 100755 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe b/Example3/bin/Debug_Ubuntu/Example3.exe index d2580fc3..b2d0f3c6 100755 Binary files a/Example3/bin/Debug_Ubuntu/Example3.exe and b/Example3/bin/Debug_Ubuntu/Example3.exe differ diff --git a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll index e7cc86f5..06cb0344 100755 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/MessageEventArgs.cs b/websocket-sharp/MessageEventArgs.cs index 26c2bdf7..073923d0 100644 --- a/websocket-sharp/MessageEventArgs.cs +++ b/websocket-sharp/MessageEventArgs.cs @@ -43,19 +43,20 @@ namespace WebSocketSharp { { #region Private Fields - private byte[] _data; + private string _data; private Opcode _opcode; + private byte[] _rawData; #endregion #region Internal Constructors - internal MessageEventArgs(Opcode opcode, byte[] data) + internal MessageEventArgs(Opcode opcode, byte[] rawData) { - if ((ulong)data.LongLength > PayloadData.MaxLength) + if ((ulong)rawData.LongLength > PayloadData.MaxLength) throw new WebSocketException(CloseStatusCode.TOO_BIG); - init(opcode, data); + init(opcode, rawData); } internal MessageEventArgs(Opcode opcode, PayloadData data) @@ -75,11 +76,10 @@ namespace WebSocketSharp { /// public string Data { get { - return _opcode == Opcode.TEXT || _opcode == Opcode.PING || _opcode == Opcode.PONG - ? _data.LongLength > 0 - ? Encoding.UTF8.GetString(_data) - : String.Empty - : _opcode.ToString(); + if (_data.IsNull()) + _data = toString(_opcode, _rawData); + + return _data; } } @@ -91,7 +91,7 @@ namespace WebSocketSharp { /// public byte[] RawData { get { - return _data; + return _rawData; } } @@ -111,10 +111,20 @@ namespace WebSocketSharp { #region Private Methods - private void init(Opcode opcode, byte[] data) + private void init(Opcode opcode, byte[] rawData) { _opcode = opcode; - _data = data; + _rawData = rawData; + } + + private static string toString(Opcode opcode, byte[] rawData) + { + if (rawData.LongLength == 0) + return String.Empty; + + return opcode == Opcode.TEXT || opcode == Opcode.PING || opcode == Opcode.PONG + ? Encoding.UTF8.GetString(rawData) + : opcode.ToString(); } #endregion diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index e7cc86f5..06cb0344 100755 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ