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