Fix due to the modified WebSocket.cs
This commit is contained in:
@@ -125,7 +125,7 @@ namespace WebSocketSharp.Server {
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Method
|
||||
#region Private Methods
|
||||
|
||||
private Dictionary<string, WebSocketService> copySessions()
|
||||
{
|
||||
@@ -175,10 +175,7 @@ namespace WebSocketSharp.Server {
|
||||
lock (_syncRoot)
|
||||
{
|
||||
foreach (var service in _sessions.Values)
|
||||
if (_isStopped || _isSweeping)
|
||||
service.Send(data);
|
||||
else
|
||||
service.SendAsync(data);
|
||||
service.Send(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,10 +184,7 @@ namespace WebSocketSharp.Server {
|
||||
lock (_syncRoot)
|
||||
{
|
||||
foreach (var service in _sessions.Values)
|
||||
if (_isStopped || _isSweeping)
|
||||
service.Send(data);
|
||||
else
|
||||
service.SendAsync(data);
|
||||
service.Send(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -193,26 +193,6 @@ namespace WebSocketSharp.Server {
|
||||
_socket.Send(data);
|
||||
}
|
||||
|
||||
public void SendAsync(byte[] data)
|
||||
{
|
||||
WaitCallback sendCb = (state) =>
|
||||
{
|
||||
Send(data);
|
||||
};
|
||||
|
||||
ThreadPool.QueueUserWorkItem(sendCb);
|
||||
}
|
||||
|
||||
public void SendAsync(string data)
|
||||
{
|
||||
WaitCallback sendCb = (state) =>
|
||||
{
|
||||
Send(data);
|
||||
};
|
||||
|
||||
ThreadPool.QueueUserWorkItem(sendCb);
|
||||
}
|
||||
|
||||
public void SendTo(string id, byte[] data)
|
||||
{
|
||||
if (!IsBound)
|
||||
|
@@ -1041,6 +1041,26 @@ 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<Opcode, Stream> action = send;
|
||||
AsyncCallback callback = null;
|
||||
callback = (ar) =>
|
||||
{
|
||||
action.EndInvoke(ar);
|
||||
stream.Close();
|
||||
if (!completed.IsNull())
|
||||
completed();
|
||||
};
|
||||
|
||||
action.BeginInvoke(opcode, stream, callback, null);
|
||||
}
|
||||
|
||||
private long sendFragmented(Opcode opcode, Stream stream)
|
||||
{
|
||||
var length = stream.Length;
|
||||
@@ -1345,6 +1365,40 @@ namespace WebSocketSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAsync(string data, Action completed)
|
||||
{
|
||||
if (data.IsNull())
|
||||
{
|
||||
onError("'data' must not be null.");
|
||||
return;
|
||||
}
|
||||
|
||||
var buffer = Encoding.UTF8.GetBytes(data);
|
||||
sendAsync(Opcode.TEXT, buffer, completed);
|
||||
}
|
||||
|
||||
public void SendAsync(byte[] data, Action completed)
|
||||
{
|
||||
if (data.IsNull())
|
||||
{
|
||||
onError("'data' must not be null.");
|
||||
return;
|
||||
}
|
||||
|
||||
sendAsync(Opcode.BINARY, data, completed);
|
||||
}
|
||||
|
||||
public void SendAsync(FileInfo file, Action completed)
|
||||
{
|
||||
if (file.IsNull())
|
||||
{
|
||||
onError("'file' must not be null.");
|
||||
return;
|
||||
}
|
||||
|
||||
sendAsync(Opcode.BINARY, file.OpenRead(), completed);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user