Exemple #1
0
 public async Task Send(WebSocketPacket packet)
 {
     foreach (WebSocketServerBase webSocketServer in this.webSocketServers)
     {
         await webSocketServer.Send(packet);
     }
 }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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(); }
        }
Exemple #4
0
 public async Task Send(WebSocketPacket packet)
 {
     await this.Send(JsonConvert.SerializeObject(packet));
 }