diff --git a/Example/bin/Debug_Ubuntu/example.exe b/Example/bin/Debug_Ubuntu/example.exe
index d29983bb..d7d6fb52 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 7ab312a3..41736fd4 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 0dd77fa2..b288785d 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 7ab312a3..41736fd4 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 5d3a8c8b..2faa8c55 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 7ab312a3..41736fd4 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 e1e7fdff..4eee9dbb 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 7ab312a3..41736fd4 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/WebSocket.cs b/websocket-sharp/WebSocket.cs
index 4e9ed028..77b4c111 100644
--- a/websocket-sharp/WebSocket.cs
+++ b/websocket-sharp/WebSocket.cs
@@ -275,14 +275,13 @@ namespace WebSocketSharp {
/// Gets a value indicating whether the WebSocket connection is alive.
///
///
- /// true if the connection is alive; otherwise, false.
+ /// true if the WebSocket connection is alive; otherwise, false.
///
public bool IsAlive {
get {
- if (_readyState != WsState.OPEN)
- return false;
-
- return Ping();
+ return _readyState == WsState.OPEN
+ ? ping(new byte[]{})
+ : false;
}
}
@@ -869,21 +868,14 @@ namespace WebSocketSharp {
OnOpen.Emit(this, EventArgs.Empty);
}
- private bool ping(string message, int millisecondsTimeout)
+ private bool ping(byte[] data)
{
- var buffer = Encoding.UTF8.GetBytes(message);
- if (buffer.Length > 125)
- {
- var msg = "The payload length of a Ping frame must be 125 bytes or less.";
- onError(msg);
- return false;
- }
-
- var frame = createControlFrame(Opcode.PING, new PayloadData(buffer), _client);
- if (!send(frame))
- return false;
+ var frame = createControlFrame(Opcode.PING, new PayloadData(data), _client);
+ var timeOut = _client ? 5000 : 1000;
- return _receivePong.WaitOne(millisecondsTimeout);
+ return send(frame)
+ ? _receivePong.WaitOne(timeOut)
+ : false;
}
private void pong(PayloadData data)
@@ -892,12 +884,6 @@ namespace WebSocketSharp {
send(frame);
}
- private void pong(string data)
- {
- var payloadData = new PayloadData(data);
- pong(payloadData);
- }
-
private bool processAbnormal(WsFrame frame)
{
if (frame != null)
@@ -1485,33 +1471,38 @@ namespace WebSocketSharp {
}
///
- /// Pings using the WebSocket connection.
+ /// Sends a Ping using the WebSocket connection.
///
///
- /// true if the receives a Pong in a time; otherwise, false.
+ /// true if a instance receives a Pong in a time; otherwise, false.
///
public bool Ping()
{
- return Ping(String.Empty);
+ return ping(new byte[]{});
}
///
- /// Pings with the specified using the WebSocket connection.
+ /// Sends a Ping with the specified using the WebSocket connection.
///
///
- /// A that contains a message.
+ /// A that contains a message to send with a Ping.
///
///
- /// true if the receives a Pong in a time; otherwise, false.
+ /// true if a instance receives a Pong in a time; otherwise, false.
///
public bool Ping(string message)
{
- if (message == null)
- message = String.Empty;
+ if (message.IsNullOrEmpty())
+ return ping(new byte[]{});
- return _client
- ? ping(message, 5 * 1000)
- : ping(message, 1 * 1000);
+ var data = Encoding.UTF8.GetBytes(message);
+ if (data.Length > 125)
+ {
+ onError("The payload length of a Ping frame must be 125 bytes or less.");
+ return false;
+ }
+
+ return ping(data);
}
///
diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll
index 7ab312a3..41736fd4 100755
Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ