[Modify] Polish it

This commit is contained in:
sta 2016-12-04 17:05:55 +09:00
parent 583933993b
commit 059624f23c

View File

@ -82,6 +82,7 @@ namespace WebSocketSharp
private string _extensions; private string _extensions;
private bool _extensionsRequested; private bool _extensionsRequested;
private object _forMessageEventQueue; private object _forMessageEventQueue;
private object _forPing;
private object _forSend; private object _forSend;
private object _forState; private object _forState;
private MemoryStream _fragmentsBuffer; private MemoryStream _fragmentsBuffer;
@ -1227,6 +1228,7 @@ namespace WebSocketSharp
{ {
_compression = CompressionMethod.None; _compression = CompressionMethod.None;
_cookies = new CookieCollection (); _cookies = new CookieCollection ();
_forPing = new object ();
_forSend = new object (); _forSend = new object ();
_forState = new object (); _forState = new object ();
_messageEventQueue = new Queue<MessageEventArgs> (); _messageEventQueue = new Queue<MessageEventArgs> ();
@ -1327,15 +1329,17 @@ namespace WebSocketSharp
if (receivePong == null) if (receivePong == null)
return false; return false;
try { lock (_forPing) {
receivePong.Reset (); try {
if (!send (Fin.Final, Opcode.Ping, data, false)) receivePong.Reset ();
return false; if (!send (Fin.Final, Opcode.Ping, data, false))
return false;
return receivePong.WaitOne (_waitTime); return receivePong.WaitOne (_waitTime);
} }
catch (ObjectDisposedException) { catch (ObjectDisposedException) {
return false; return false;
}
} }
} }