public override async Task OnSessionTextReceived(AsyncWebSocketSession session, string text)
        {
            Console.Write(string.Format("WebSocket session [{0}] received Text --> ", session.RemoteEndPoint));
            Console.WriteLine(string.Format("{0}", text));

            await session.SendTextAsync(text);
        }
Beispiel #2
0
        public override async Task OnSessionBinaryReceived(AsyncWebSocketSession session, byte[] data, int offset, int count)
        {
            var text = Encoding.UTF8.GetString(data, offset, count);
            Console.Write(string.Format("WebSocket session [{0}] received Binary --> ", session.RemoteEndPoint));
            Console.WriteLine(string.Format("{0}", text));

            await session.SendBinaryAsync(Encoding.UTF8.GetBytes(text));
        }
Beispiel #3
0
        public override async Task OnSessionBinaryReceived(AsyncWebSocketSession session, byte[] data, int offset, int count)
        {
            var text = Encoding.UTF8.GetString(data, offset, count);

            Console.Write(string.Format("WebSocket session [{0}] received Binary --> ", session.RemoteEndPoint));
            if (count < 1024 * 1024 * 1)
            {
                Console.WriteLine(text);
            }
            else
            {
                Console.WriteLine("{0} Bytes", count);
            }

            await session.SendBinaryAsync(Encoding.UTF8.GetBytes(text));
        }
Beispiel #4
0
 public override async Task OnSessionClosed(AsyncWebSocketSession session)
 {
     Console.WriteLine(string.Format("WebSocket session [{0}] has disconnected.", session.RemoteEndPoint));
     await Task.CompletedTask;
 }
 public override async Task OnSessionClosed(AsyncWebSocketSession session)
 {
     Console.WriteLine(string.Format("WebSocket session [{0}] has disconnected.", session.RemoteEndPoint));
     await Task.CompletedTask;
 }