Ejemplo n.º 1
0
 public async Task ServerSendData(AsyncTcpServerSession session, byte[] code, byte[] body)
 {
     try
     {
         byte[] data = new byte[body.Length + 4];
         Array.Copy(code, 0, data, 0, 4);
         Array.Copy(body, 0, data, 4, body.Length);
         await session.SendAsync(data);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex);
     }
 }
Ejemplo n.º 2
0
        public async Task OnSessionDataReceived(AsyncTcpServerSession session, byte[] data, int offset, int count)
        {
            var text = Encoding.UTF8.GetString(data, offset, count);

            Console.Write($"Client : {session.RemoteEndPoint} --> ");
            if (count < 1024 * 1024 * 1)
            {
                Console.WriteLine(text);
            }
            else
            {
                Console.WriteLine("{0} Bytes", count);
            }

            await session.SendAsync(Encoding.UTF8.GetBytes(text));
        }