Modified SendTo and BroadcastTo methods
This commit is contained in:
parent
133ff88b0d
commit
f103cd2faf
@ -359,66 +359,58 @@ namespace WebSocketSharp.Server
|
||||
/// Broadcasts the specified array of <see cref="byte"/> to all clients of the WebSocket service
|
||||
/// with the specified <paramref name="servicePath"/>.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="data"/> is broadcasted; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <param name="data">
|
||||
/// An array of <see cref="byte"/> to broadcast.
|
||||
/// </param>
|
||||
/// <param name="servicePath">
|
||||
/// A <see cref="string"/> that contains an absolute path to the WebSocket service to find.
|
||||
/// </param>
|
||||
public bool BroadcastTo (byte [] data, string servicePath)
|
||||
public void BroadcastTo (byte [] data, string servicePath)
|
||||
{
|
||||
var msg = _state.CheckIfStarted () ?? data.CheckIfValidSendData () ?? servicePath.CheckIfValidServicePath ();
|
||||
if (msg != null)
|
||||
{
|
||||
_logger.Error (msg);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
IWebSocketServiceHost host;
|
||||
if (!TryGetServiceHostInternally (servicePath, out host))
|
||||
{
|
||||
_logger.Error ("The WebSocket service with the specified path not found.\npath: " + servicePath);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
host.Sessions.BroadcastInternally (data);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broadcasts the specified <see cref="string"/> to all clients of the WebSocket service
|
||||
/// with the specified <paramref name="servicePath"/>.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="data"/> is broadcasted; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <param name="data">
|
||||
/// A <see cref="string"/> to broadcast.
|
||||
/// </param>
|
||||
/// <param name="servicePath">
|
||||
/// A <see cref="string"/> that contains an absolute path to the WebSocket service to find.
|
||||
/// </param>
|
||||
public bool BroadcastTo (string data, string servicePath)
|
||||
public void BroadcastTo (string data, string servicePath)
|
||||
{
|
||||
var msg = _state.CheckIfStarted () ?? data.CheckIfValidSendData () ?? servicePath.CheckIfValidServicePath ();
|
||||
if (msg != null)
|
||||
{
|
||||
_logger.Error (msg);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
IWebSocketServiceHost host;
|
||||
if (!TryGetServiceHostInternally (servicePath, out host))
|
||||
{
|
||||
_logger.Error ("The WebSocket service with the specified path not found.\npath: " + servicePath);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
host.Sessions.BroadcastInternally (data);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -710,9 +702,6 @@ namespace WebSocketSharp.Server
|
||||
/// Sends a binary <paramref name="data"/> to the client associated with the specified
|
||||
/// <paramref name="id"/> and <paramref name="servicePath"/>.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="data"/> is successfully sent; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <param name="data">
|
||||
/// An array of <see cref="byte"/> that contains a binary data to send.
|
||||
/// </param>
|
||||
@ -722,32 +711,29 @@ namespace WebSocketSharp.Server
|
||||
/// <param name="servicePath">
|
||||
/// A <see cref="string"/> that contains an absolute path to the WebSocket service to find.
|
||||
/// </param>
|
||||
public bool SendTo (byte [] data, string id, string servicePath)
|
||||
public void SendTo (byte [] data, string id, string servicePath)
|
||||
{
|
||||
var msg = _state.CheckIfStarted () ?? servicePath.CheckIfValidServicePath ();
|
||||
if (msg != null)
|
||||
{
|
||||
_logger.Error (msg);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
IWebSocketServiceHost host;
|
||||
if (!TryGetServiceHostInternally (servicePath, out host))
|
||||
{
|
||||
_logger.Error ("The WebSocket service with the specified path not found.\npath: " + servicePath);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
return host.Sessions.SendTo (data, id);
|
||||
host.Sessions.SendTo (data, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a text <paramref name="data"/> to the client associated with the specified
|
||||
/// <paramref name="id"/> and <paramref name="servicePath"/>.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="data"/> is successfully sent; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <param name="data">
|
||||
/// A <see cref="string"/> that contains a text data to send.
|
||||
/// </param>
|
||||
@ -757,23 +743,23 @@ namespace WebSocketSharp.Server
|
||||
/// <param name="servicePath">
|
||||
/// A <see cref="string"/> that contains an absolute path to the WebSocket service to find.
|
||||
/// </param>
|
||||
public bool SendTo (string data, string id, string servicePath)
|
||||
public void SendTo (string data, string id, string servicePath)
|
||||
{
|
||||
var msg = _state.CheckIfStarted () ?? servicePath.CheckIfValidServicePath ();
|
||||
if (msg != null)
|
||||
{
|
||||
_logger.Error (msg);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
IWebSocketServiceHost host;
|
||||
if (!TryGetServiceHostInternally (servicePath, out host))
|
||||
{
|
||||
_logger.Error ("The WebSocket service with the specified path not found.\npath: " + servicePath);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
return host.Sessions.SendTo (data, id);
|
||||
host.Sessions.SendTo (data, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -586,66 +586,58 @@ namespace WebSocketSharp.Server
|
||||
/// Sends a binary <paramref name="data"/> to the client associated with the specified
|
||||
/// <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="data"/> is successfully sent; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <param name="data">
|
||||
/// An array of <see cref="byte"/> that contains a binary data to send.
|
||||
/// </param>
|
||||
/// <param name="id">
|
||||
/// A <see cref="string"/> that contains a session ID that represents the destination for the data.
|
||||
/// </param>
|
||||
public bool SendTo (byte [] data, string id)
|
||||
public void SendTo (byte [] data, string id)
|
||||
{
|
||||
var msg = _state.CheckIfStarted () ?? id.CheckIfValidSessionID ();
|
||||
if (msg != null)
|
||||
{
|
||||
_logger.Error (msg);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
WebSocketService service;
|
||||
if (!TryGetServiceInstance (id, out service))
|
||||
{
|
||||
_logger.Error ("The WebSocket session with the specified ID not found.\nID: " + id);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
service.Send (data);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a text <paramref name="data"/> to the client associated with the specified
|
||||
/// <paramref name="id"/>.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="data"/> is successfully sent; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
/// <param name="data">
|
||||
/// A <see cref="string"/> that contains a text data to send.
|
||||
/// </param>
|
||||
/// <param name="id">
|
||||
/// A <see cref="string"/> that contains a session ID that represents the destination for the data.
|
||||
/// </param>
|
||||
public bool SendTo (string data, string id)
|
||||
public void SendTo (string data, string id)
|
||||
{
|
||||
var msg = _state.CheckIfStarted () ?? id.CheckIfValidSessionID ();
|
||||
if (msg != null)
|
||||
{
|
||||
_logger.Error (msg);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
WebSocketService service;
|
||||
if (!TryGetServiceInstance (id, out service))
|
||||
{
|
||||
_logger.Error ("The WebSocket session with the specified ID not found.\nID: " + id);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
service.Send (data);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user