From f103cd2faf3fbacca86d4ef16692e3c7f8fe8363 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 27 Sep 2013 22:20:00 +0900 Subject: [PATCH] Modified SendTo and BroadcastTo methods --- .../Server/WebSocketServiceHostManager.cs | 42 +++++++------------ .../Server/WebSocketSessionManager.cs | 20 +++------ 2 files changed, 20 insertions(+), 42 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceHostManager.cs b/websocket-sharp/Server/WebSocketServiceHostManager.cs index 56b4be4f..e6c76357 100644 --- a/websocket-sharp/Server/WebSocketServiceHostManager.cs +++ b/websocket-sharp/Server/WebSocketServiceHostManager.cs @@ -359,66 +359,58 @@ namespace WebSocketSharp.Server /// Broadcasts the specified array of to all clients of the WebSocket service /// with the specified . /// - /// - /// true if is broadcasted; otherwise, false. - /// /// /// An array of to broadcast. /// /// /// A that contains an absolute path to the WebSocket service to find. /// - 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; } /// /// Broadcasts the specified to all clients of the WebSocket service /// with the specified . /// - /// - /// true if is broadcasted; otherwise, false. - /// /// /// A to broadcast. /// /// /// A that contains an absolute path to the WebSocket service to find. /// - 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; } /// @@ -710,9 +702,6 @@ namespace WebSocketSharp.Server /// Sends a binary to the client associated with the specified /// and . /// - /// - /// true if is successfully sent; otherwise, false. - /// /// /// An array of that contains a binary data to send. /// @@ -722,32 +711,29 @@ namespace WebSocketSharp.Server /// /// A that contains an absolute path to the WebSocket service to find. /// - 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); } /// /// Sends a text to the client associated with the specified /// and . /// - /// - /// true if is successfully sent; otherwise, false. - /// /// /// A that contains a text data to send. /// @@ -757,23 +743,23 @@ namespace WebSocketSharp.Server /// /// A that contains an absolute path to the WebSocket service to find. /// - 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); } /// diff --git a/websocket-sharp/Server/WebSocketSessionManager.cs b/websocket-sharp/Server/WebSocketSessionManager.cs index 713c2f82..de9c1ce3 100644 --- a/websocket-sharp/Server/WebSocketSessionManager.cs +++ b/websocket-sharp/Server/WebSocketSessionManager.cs @@ -586,66 +586,58 @@ namespace WebSocketSharp.Server /// Sends a binary to the client associated with the specified /// . /// - /// - /// true if is successfully sent; otherwise, false. - /// /// /// An array of that contains a binary data to send. /// /// /// A that contains a session ID that represents the destination for the data. /// - 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; } /// /// Sends a text to the client associated with the specified /// . /// - /// - /// true if is successfully sent; otherwise, false. - /// /// /// A that contains a text data to send. /// /// /// A that contains a session ID that represents the destination for the data. /// - 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; } ///