diff --git a/Example/bin/Debug/example.exe b/Example/bin/Debug/example.exe index d34f8f9d..928c33c0 100755 Binary files a/Example/bin/Debug/example.exe and b/Example/bin/Debug/example.exe differ diff --git a/Example/bin/Debug/websocket-sharp.dll b/Example/bin/Debug/websocket-sharp.dll index dfa3bc61..8c1a6d70 100755 Binary files a/Example/bin/Debug/websocket-sharp.dll and b/Example/bin/Debug/websocket-sharp.dll differ diff --git a/Example/bin/Debug_Ubuntu/example.exe b/Example/bin/Debug_Ubuntu/example.exe index 91c4c081..d29983bb 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 4b8ecf2c..7ab312a3 100755 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example/bin/Release/example.exe b/Example/bin/Release/example.exe index 18cbc680..cf7556c2 100755 Binary files a/Example/bin/Release/example.exe and b/Example/bin/Release/example.exe differ diff --git a/Example/bin/Release/websocket-sharp.dll b/Example/bin/Release/websocket-sharp.dll index 8a2dc0c8..98fb2755 100755 Binary files a/Example/bin/Release/websocket-sharp.dll and b/Example/bin/Release/websocket-sharp.dll differ diff --git a/Example/bin/Release_Ubuntu/example.exe b/Example/bin/Release_Ubuntu/example.exe index 93cb1868..0b062170 100755 Binary files a/Example/bin/Release_Ubuntu/example.exe and b/Example/bin/Release_Ubuntu/example.exe differ diff --git a/Example/bin/Release_Ubuntu/websocket-sharp.dll b/Example/bin/Release_Ubuntu/websocket-sharp.dll index c318c3a8..bc20f551 100755 Binary files a/Example/bin/Release_Ubuntu/websocket-sharp.dll and b/Example/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/Example1/bin/Debug/example1.exe b/Example1/bin/Debug/example1.exe index 7ca94251..fb367dd6 100755 Binary files a/Example1/bin/Debug/example1.exe and b/Example1/bin/Debug/example1.exe differ diff --git a/Example1/bin/Debug/websocket-sharp.dll b/Example1/bin/Debug/websocket-sharp.dll index dfa3bc61..8c1a6d70 100755 Binary files a/Example1/bin/Debug/websocket-sharp.dll and b/Example1/bin/Debug/websocket-sharp.dll differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe b/Example1/bin/Debug_Ubuntu/example1.exe index 2a0669bf..0dd77fa2 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 4b8ecf2c..7ab312a3 100755 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example1/bin/Release/example1.exe b/Example1/bin/Release/example1.exe index 48a3d53e..ab89d680 100755 Binary files a/Example1/bin/Release/example1.exe and b/Example1/bin/Release/example1.exe differ diff --git a/Example1/bin/Release/websocket-sharp.dll b/Example1/bin/Release/websocket-sharp.dll index 8a2dc0c8..98fb2755 100755 Binary files a/Example1/bin/Release/websocket-sharp.dll and b/Example1/bin/Release/websocket-sharp.dll differ diff --git a/Example1/bin/Release_Ubuntu/example1.exe b/Example1/bin/Release_Ubuntu/example1.exe index afdd0a03..302c2d66 100755 Binary files a/Example1/bin/Release_Ubuntu/example1.exe and b/Example1/bin/Release_Ubuntu/example1.exe differ diff --git a/Example1/bin/Release_Ubuntu/websocket-sharp.dll b/Example1/bin/Release_Ubuntu/websocket-sharp.dll index c318c3a8..bc20f551 100755 Binary files a/Example1/bin/Release_Ubuntu/websocket-sharp.dll and b/Example1/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/Example2/bin/Debug/example2.exe b/Example2/bin/Debug/example2.exe index 666af267..209f9e2f 100755 Binary files a/Example2/bin/Debug/example2.exe and b/Example2/bin/Debug/example2.exe differ diff --git a/Example2/bin/Debug/websocket-sharp.dll b/Example2/bin/Debug/websocket-sharp.dll index dfa3bc61..8c1a6d70 100755 Binary files a/Example2/bin/Debug/websocket-sharp.dll and b/Example2/bin/Debug/websocket-sharp.dll differ diff --git a/Example2/bin/Debug_Ubuntu/example2.exe b/Example2/bin/Debug_Ubuntu/example2.exe index 1a590498..5d3a8c8b 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 4b8ecf2c..7ab312a3 100755 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example2/bin/Release/example2.exe b/Example2/bin/Release/example2.exe index fc123ca5..7213d771 100755 Binary files a/Example2/bin/Release/example2.exe and b/Example2/bin/Release/example2.exe differ diff --git a/Example2/bin/Release/websocket-sharp.dll b/Example2/bin/Release/websocket-sharp.dll index 8a2dc0c8..98fb2755 100755 Binary files a/Example2/bin/Release/websocket-sharp.dll and b/Example2/bin/Release/websocket-sharp.dll differ diff --git a/Example2/bin/Release_Ubuntu/example2.exe b/Example2/bin/Release_Ubuntu/example2.exe index 66647dbd..1ba06775 100755 Binary files a/Example2/bin/Release_Ubuntu/example2.exe and b/Example2/bin/Release_Ubuntu/example2.exe differ diff --git a/Example2/bin/Release_Ubuntu/websocket-sharp.dll b/Example2/bin/Release_Ubuntu/websocket-sharp.dll index c318c3a8..bc20f551 100755 Binary files a/Example2/bin/Release_Ubuntu/websocket-sharp.dll and b/Example2/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/Example3/bin/Debug/Example3.exe b/Example3/bin/Debug/Example3.exe index c60d3eaa..e3dbae18 100755 Binary files a/Example3/bin/Debug/Example3.exe and b/Example3/bin/Debug/Example3.exe differ diff --git a/Example3/bin/Debug/websocket-sharp.dll b/Example3/bin/Debug/websocket-sharp.dll index dfa3bc61..8c1a6d70 100755 Binary files a/Example3/bin/Debug/websocket-sharp.dll and b/Example3/bin/Debug/websocket-sharp.dll differ diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe b/Example3/bin/Debug_Ubuntu/Example3.exe index 56b265e8..e1e7fdff 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 4b8ecf2c..7ab312a3 100755 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example3/bin/Release/Example3.exe b/Example3/bin/Release/Example3.exe index 26292ee2..8046a341 100755 Binary files a/Example3/bin/Release/Example3.exe and b/Example3/bin/Release/Example3.exe differ diff --git a/Example3/bin/Release/websocket-sharp.dll b/Example3/bin/Release/websocket-sharp.dll index 8a2dc0c8..98fb2755 100755 Binary files a/Example3/bin/Release/websocket-sharp.dll and b/Example3/bin/Release/websocket-sharp.dll differ diff --git a/Example3/bin/Release_Ubuntu/Example3.exe b/Example3/bin/Release_Ubuntu/Example3.exe index 9c56b19e..c0f40492 100755 Binary files a/Example3/bin/Release_Ubuntu/Example3.exe and b/Example3/bin/Release_Ubuntu/Example3.exe differ diff --git a/Example3/bin/Release_Ubuntu/websocket-sharp.dll b/Example3/bin/Release_Ubuntu/websocket-sharp.dll index c318c3a8..bc20f551 100755 Binary files a/Example3/bin/Release_Ubuntu/websocket-sharp.dll and b/Example3/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 626abb49..4e9ed028 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -143,7 +143,7 @@ namespace WebSocketSharp { public WebSocket(string url, params string[] protocols) : this() { - if (url.IsNull()) + if (url == null) throw new ArgumentNullException("url"); Uri uri; @@ -332,7 +332,7 @@ namespace WebSocketSharp { var origin = new Uri(value); if (!origin.IsAbsoluteUri || origin.Segments.Length > 1) { - onError("The syntax of value must be '://[:]'."); + onError("The syntax of value of Origin must be '://[:]'."); return; } @@ -524,13 +524,13 @@ namespace WebSocketSharp { // As client private void closeResourcesAsClient() { - if (!_wsStream.IsNull()) + if (_wsStream != null) { _wsStream.Dispose(); _wsStream = null; } - if (!_tcpClient.IsNull()) + if (_tcpClient != null) { _tcpClient.Close(); _tcpClient = null; @@ -540,11 +540,11 @@ namespace WebSocketSharp { // As server private void closeResourcesAsServer() { - if (!_context.IsNull() && !_closeContext.IsNull()) + if (_context != null && _closeContext != null) { _closeContext(); _wsStream = null; - _context = null; + _context = null; } } @@ -561,7 +561,7 @@ namespace WebSocketSharp { while (true) { - var frame = readFrame(); + var frame = _wsStream.ReadFrame(); if (processAbnormal(frame)) return false; @@ -622,7 +622,10 @@ namespace WebSocketSharp { private static WsFrame createControlFrame(Opcode opcode, PayloadData payloadData, bool client) { - return createFrame(Fin.FINAL, opcode, payloadData, false, client); + var mask = client ? Mask.MASK : Mask.UNMASK; + var frame = new WsFrame(Fin.FINAL, opcode, mask, payloadData); + + return frame; } private static string createCurrentCompressionExtension(CompressionMethod method) @@ -653,7 +656,7 @@ namespace WebSocketSharp { { var extensions = new StringBuilder(64); var comp = createCompressionExtension(_compression); - if (!comp.IsEmpty()) + if (comp.Length > 0) extensions.Append(comp); return extensions.Length > 0 @@ -672,7 +675,7 @@ namespace WebSocketSharp { var req = new RequestHandshake(path); req.AddHeader("Host", host); - if (!_origin.IsEmpty()) + if (_origin.Length > 0) req.AddHeader("Origin", _origin); req.AddHeader("Sec-WebSocket-Key", _base64key); @@ -681,7 +684,7 @@ namespace WebSocketSharp { req.AddHeader("Sec-WebSocket-Protocol", _protocols); var extensions = createRequestExtensions(); - if (!extensions.IsEmpty()) + if (extensions.Length > 0) req.AddHeader("Sec-WebSocket-Extensions", extensions); req.AddHeader("Sec-WebSocket-Version", _version); @@ -697,7 +700,7 @@ namespace WebSocketSharp { { var res = new ResponseHandshake(); res.AddHeader("Sec-WebSocket-Accept", createResponseKey()); - if (!_extensions.IsEmpty()) + if (_extensions.Length > 0) res.AddHeader("Sec-WebSocket-Extensions", _extensions); if (_cookies.Count > 0) @@ -774,7 +777,7 @@ namespace WebSocketSharp { private static bool isCompressionExtension(string value, CompressionMethod method) { var expected = createCompressionExtension(method); - return !expected.IsEmpty() + return expected.Length > 0 ? value.Equals(expected) : false; } @@ -834,7 +837,7 @@ namespace WebSocketSharp { private void onClose(CloseEventArgs eventArgs) { if (!Thread.CurrentThread.IsBackground) - if (!_exitReceiving.IsNull()) + if (_exitReceiving != null) _exitReceiving.WaitOne(5 * 1000); if (!closeResources()) @@ -855,7 +858,7 @@ namespace WebSocketSharp { private void onMessage(MessageEventArgs eventArgs) { - if (!eventArgs.IsNull()) + if (eventArgs != null) OnMessage.Emit(this, eventArgs); } @@ -897,7 +900,7 @@ namespace WebSocketSharp { private bool processAbnormal(WsFrame frame) { - if (!frame.IsNull()) + if (frame != null) return false; #if DEBUG @@ -950,7 +953,7 @@ namespace WebSocketSharp { return false; bool incorrect = !frame.IsData || - frame.IsCompressed && _compression == CompressionMethod.NONE; + (frame.IsCompressed && _compression == CompressionMethod.NONE); if (!incorrect) processFragments(frame); @@ -1055,7 +1058,7 @@ namespace WebSocketSharp { } if (buffer.Count > 0) - _extensions = buffer.ToArray().ToString(","); + _extensions = buffer.ToArray().ToString(", "); } // As server @@ -1147,20 +1150,10 @@ namespace WebSocketSharp { _protocol = protocol; } - private WsFrame readFrame() - { - return _wsStream.ReadFrame(); - } - - private string[] readHandshake() - { - return _wsStream.ReadHandshake(); - } - // As client private ResponseHandshake receiveResponseHandshake() { - var res = ResponseHandshake.Parse(readHandshake()); + var res = ResponseHandshake.Parse(_wsStream.ReadHandshake()); #if DEBUG Console.WriteLine("WS: Info@receiveResponseHandshake: Response handshake from server:\n"); Console.WriteLine(res.ToString()); @@ -1198,7 +1191,7 @@ namespace WebSocketSharp { try { - if (_wsStream.IsNull()) + if (_wsStream == null) return false; _wsStream.Write(frame); @@ -1211,14 +1204,6 @@ namespace WebSocketSharp { } } - private void send(Opcode opcode, byte[] data) - { - using (MemoryStream ms = new MemoryStream(data)) - { - send(opcode, ms); - } - } - private void send(Opcode opcode, Stream stream) { if (_compression == CompressionMethod.NONE) @@ -1264,21 +1249,15 @@ namespace WebSocketSharp { return send(frame); } - private void sendAsync(Opcode opcode, byte[] data, Action completed) - { - sendAsync(opcode, new MemoryStream(data), completed); - } - private void sendAsync(Opcode opcode, Stream stream, Action completed) { Action action = send; - AsyncCallback callback = (ar) => { try { action.EndInvoke(ar); - if (!completed.IsNull()) + if (completed != null) completed(); } catch (Exception ex) @@ -1527,7 +1506,7 @@ namespace WebSocketSharp { /// public bool Ping(string message) { - if (message.IsNull()) + if (message == null) message = String.Empty; return _client @@ -1543,13 +1522,16 @@ namespace WebSocketSharp { /// public void Send(byte[] data) { - if (data.IsNull()) + if (data == null) { onError("'data' must not be null."); return; } - send(Opcode.BINARY, data); + using (var ms = new MemoryStream(data)) + { + send(Opcode.BINARY, ms); + } } /// @@ -1560,14 +1542,16 @@ namespace WebSocketSharp { /// public void Send(string data) { - if (data.IsNull()) + if (data == null) { onError("'data' must not be null."); return; } - var buffer = Encoding.UTF8.GetBytes(data); - send(Opcode.TEXT, buffer); + using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(data))) + { + send(Opcode.TEXT, ms); + } } /// @@ -1578,13 +1562,13 @@ namespace WebSocketSharp { /// public void Send(FileInfo file) { - if (file.IsNull()) + if (file == null) { onError("'file' must not be null."); return; } - using (FileStream fs = file.OpenRead()) + using (var fs = file.OpenRead()) { send(Opcode.BINARY, fs); } @@ -1602,13 +1586,14 @@ namespace WebSocketSharp { /// public void SendAsync(byte[] data, Action completed) { - if (data.IsNull()) + if (data == null) { onError("'data' must not be null."); return; } - sendAsync(Opcode.BINARY, data, completed); + var ms = new MemoryStream(data); + sendAsync(Opcode.BINARY, ms, completed); } /// @@ -1623,14 +1608,14 @@ namespace WebSocketSharp { /// public void SendAsync(string data, Action completed) { - if (data.IsNull()) + if (data == null) { onError("'data' must not be null."); return; } - var buffer = Encoding.UTF8.GetBytes(data); - sendAsync(Opcode.TEXT, buffer, completed); + var ms = new MemoryStream(Encoding.UTF8.GetBytes(data)); + sendAsync(Opcode.TEXT, ms, completed); } /// @@ -1645,7 +1630,7 @@ namespace WebSocketSharp { /// public void SendAsync(FileInfo file, Action completed) { - if (file.IsNull()) + if (file == null) { onError("'file' must not be null."); return; @@ -1665,7 +1650,7 @@ namespace WebSocketSharp { if (isOpened(true)) return; - if (cookie.IsNull()) + if (cookie == null) { onError("'cookie' must not be null."); return; diff --git a/websocket-sharp/bin/Debug/websocket-sharp.dll b/websocket-sharp/bin/Debug/websocket-sharp.dll index dfa3bc61..8c1a6d70 100755 Binary files a/websocket-sharp/bin/Debug/websocket-sharp.dll and b/websocket-sharp/bin/Debug/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index dc04ea62..7ab312a3 100755 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Release/websocket-sharp.dll b/websocket-sharp/bin/Release/websocket-sharp.dll index 8a2dc0c8..98fb2755 100755 Binary files a/websocket-sharp/bin/Release/websocket-sharp.dll and b/websocket-sharp/bin/Release/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll index c318c3a8..bc20f551 100755 Binary files a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/doc/mdoc/index.xml b/websocket-sharp/doc/mdoc/index.xml index 563ba9ea..526bf519 100644 --- a/websocket-sharp/doc/mdoc/index.xml +++ b/websocket-sharp/doc/mdoc/index.xml @@ -1,6 +1,6 @@ - + [00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 11 00 00 00 29 17 fb 89 fe c3 91 f7 2b cb 8b e2 61 d2 3f 05 93 6d 65 a8 9e 63 72 a6 f5 d5 2c f2 9d 20 fa 0b c0 70 6a f6 88 7e 8b 90 3f 39 f5 76 c8 48 e0 bb 7b b2 7b ed d3 10 a7 1a 0f 70 98 0f 7f f4 4b 53 09 d2 a5 ef 36 c3 56 b4 aa f0 91 72 63 25 07 89 e0 93 3e 3f 2e f2 b9 73 0e 12 15 5d 43 56 c3 f4 70 a5 89 fe f7 f6 ac 3e 77 c2 d8 d0 84 91 f4 0c d1 f3 8e dc c3 c3 b8 38 3d 0c bf 17 de 20 78 c1 ]