public async Task Send(WebSocketPacket packet) { foreach (WebSocketServerBase webSocketServer in this.webSocketServers) { await webSocketServer.Send(packet); } }
public async Task Send(WebSocketPacket packet) { try { foreach (WebSocketServerBase webSocketServer in this.webSocketServers) { Logger.Log(LogLevel.Debug, "Sending Web Socket Packet - " + JSONSerializerHelper.SerializeToString(packet)); await webSocketServer.Send(packet); } } catch (Exception ex) { Logger.Log(ex); } }
public async Task Send(WebSocketPacket packet) { try { string packetJson = JsonConvert.SerializeObject(packet); byte[] buffer = this.encoder.GetBytes(packetJson); await this.asyncSemaphore.WaitAsync(); if (this.webSocket != null) { await this.webSocket.SendAsync(new ArraySegment <byte>(buffer), WebSocketMessageType.Text, true, CancellationToken.None); } } catch (Exception ex) { Logger.Log(ex); } finally { this.asyncSemaphore.Release(); } }
public async Task Send(WebSocketPacket packet) { await this.Send(JsonConvert.SerializeObject(packet)); }