Fixed several part
This commit is contained in:
parent
a93dcc09aa
commit
cf6b26503e
@ -108,7 +108,7 @@ namespace Example
|
|||||||
|
|
||||||
_ws.OnError += (sender, e) =>
|
_ws.OnError += (sender, e) =>
|
||||||
{
|
{
|
||||||
enNfMessage("[AudioStreamer] error", "WS Error: " + e.Data, "notification-message-im");
|
enNfMessage("[AudioStreamer] error", "WS: Error: " + e.Data, "notification-message-im");
|
||||||
};
|
};
|
||||||
|
|
||||||
_ws.OnClose += (sender, e) =>
|
_ws.OnClose += (sender, e) =>
|
||||||
@ -116,7 +116,7 @@ namespace Example
|
|||||||
enNfMessage
|
enNfMessage
|
||||||
(
|
(
|
||||||
"[AudioStreamer] disconnect",
|
"[AudioStreamer] disconnect",
|
||||||
String.Format("WS Close({0}:{1}): {2}", (ushort)e.Code, e.Code, e.Reason),
|
String.Format("WS: Close({0}:{1}): {2}", (ushort)e.Code, e.Code, e.Reason),
|
||||||
"notification-message-im"
|
"notification-message-im"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Ubuntu" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release_Ubuntu" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="websocket-sharp/WebSocket.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="websocket-sharp/WebSocket.cs" Line="217" Column="41" />
|
<File FileName="websocket-sharp/WebSocket.cs" Line="428" Column="39" />
|
||||||
</Files>
|
</Files>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
@ -36,6 +36,25 @@ namespace WebSocketSharp
|
|||||||
{
|
{
|
||||||
public static class Ext
|
public static class Ext
|
||||||
{
|
{
|
||||||
|
public static void Emit(
|
||||||
|
this EventHandler eventHandler, object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (eventHandler != null)
|
||||||
|
{
|
||||||
|
eventHandler(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Emit<TEventArgs>(
|
||||||
|
this EventHandler<TEventArgs> eventHandler, object sender, TEventArgs e)
|
||||||
|
where TEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
if (eventHandler != null)
|
||||||
|
{
|
||||||
|
eventHandler(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool EqualsAndSaveTo(this int value, char c, List<byte> dest)
|
public static bool EqualsAndSaveTo(this int value, char c, List<byte> dest)
|
||||||
{
|
{
|
||||||
byte b = (byte)value;
|
byte b = (byte)value;
|
||||||
|
@ -47,6 +47,7 @@ namespace WebSocketSharp.Frame
|
|||||||
|
|
||||||
public byte[] ExtensionData { get; private set; }
|
public byte[] ExtensionData { get; private set; }
|
||||||
public byte[] ApplicationData { get; private set; }
|
public byte[] ApplicationData { get; private set; }
|
||||||
|
|
||||||
public bool IsMasked { get; private set; }
|
public bool IsMasked { get; private set; }
|
||||||
|
|
||||||
public ulong Length
|
public ulong Length
|
||||||
@ -154,6 +155,7 @@ namespace WebSocketSharp.Frame
|
|||||||
{
|
{
|
||||||
mask(ExtensionData, maskingKey);
|
mask(ExtensionData, maskingKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ApplicationData.LongLength > 0)
|
if (ApplicationData.LongLength > 0)
|
||||||
{
|
{
|
||||||
mask(ApplicationData, maskingKey);
|
mask(ApplicationData, maskingKey);
|
||||||
|
@ -126,10 +126,7 @@ namespace WebSocketSharp
|
|||||||
{
|
{
|
||||||
case WsState.OPEN:
|
case WsState.OPEN:
|
||||||
messageThreadStart();
|
messageThreadStart();
|
||||||
if (OnOpen != null)
|
OnOpen.Emit(this, EventArgs.Empty);
|
||||||
{
|
|
||||||
OnOpen(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WsState.CLOSING:
|
case WsState.CLOSING:
|
||||||
break;
|
break;
|
||||||
@ -229,14 +226,14 @@ namespace WebSocketSharp
|
|||||||
else if (_readyState == WsState.CONNECTING)
|
else if (_readyState == WsState.CONNECTING)
|
||||||
{
|
{
|
||||||
ReadyState = WsState.CLOSED;
|
ReadyState = WsState.CLOSED;
|
||||||
emitOnClose(data);
|
OnClose.Emit(this, new CloseEventArgs(data));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadyState = WsState.CLOSING;
|
ReadyState = WsState.CLOSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
emitOnClose(data);
|
OnClose.Emit(this, new CloseEventArgs(data));
|
||||||
var frame = new WsFrame(Opcode.CLOSE, data);
|
var frame = new WsFrame(Opcode.CLOSE, data);
|
||||||
closeHandshake(frame);
|
closeHandshake(frame);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@ -428,27 +425,14 @@ namespace WebSocketSharp
|
|||||||
ReadyState = WsState.OPEN;
|
ReadyState = WsState.OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void emitOnClose(PayloadData data)
|
|
||||||
{
|
|
||||||
if (OnClose != null)
|
|
||||||
{
|
|
||||||
OnClose(this, new CloseEventArgs(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void error(string message)
|
private void error(string message)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
var callerFrame = new StackFrame(1);
|
var callerFrame = new StackFrame(1);
|
||||||
var caller = callerFrame.GetMethod();
|
var caller = callerFrame.GetMethod();
|
||||||
|
|
||||||
if (OnError != null)
|
|
||||||
{
|
|
||||||
OnError(this, new MessageEventArgs(message));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("WS: Error@{0}: {1}", caller.Name, message);
|
Console.WriteLine("WS: Error@{0}: {1}", caller.Name, message);
|
||||||
}
|
#endif
|
||||||
|
OnError.Emit(this, new MessageEventArgs(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isValidResponse(string[] response, out string message)
|
private bool isValidResponse(string[] response, out string message)
|
||||||
@ -548,9 +532,9 @@ namespace WebSocketSharp
|
|||||||
{
|
{
|
||||||
eventArgs = receive();
|
eventArgs = receive();
|
||||||
|
|
||||||
if (OnMessage != null && eventArgs != null)
|
if (eventArgs != null)
|
||||||
{
|
{
|
||||||
OnMessage(this, eventArgs);
|
OnMessage.Emit(this, eventArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (WsReceivedTooBigMessageException ex)
|
catch (WsReceivedTooBigMessageException ex)
|
||||||
@ -630,17 +614,11 @@ namespace WebSocketSharp
|
|||||||
else if (frame.Opcode == Opcode.PING)
|
else if (frame.Opcode == Opcode.PING)
|
||||||
{// FINAL & PING
|
{// FINAL & PING
|
||||||
pong(frame.PayloadData);
|
pong(frame.PayloadData);
|
||||||
if (OnMessage != null)
|
OnMessage.Emit(this, new MessageEventArgs(frame.Opcode, frame.PayloadData));
|
||||||
{
|
|
||||||
OnMessage(this, new MessageEventArgs(frame.Opcode, frame.PayloadData));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (frame.Opcode == Opcode.PONG)
|
else if (frame.Opcode == Opcode.PONG)
|
||||||
{// FINAL & PONG
|
{// FINAL & PONG
|
||||||
if (OnMessage != null)
|
OnMessage.Emit(this, new MessageEventArgs(frame.Opcode, frame.PayloadData));
|
||||||
{
|
|
||||||
OnMessage(this, new MessageEventArgs(frame.Opcode, frame.PayloadData));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{// FINAL & (TEXT | BINARY)
|
{// FINAL & (TEXT | BINARY)
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user