public static void Visit( IVisitorQuicReceiveLoop host, ITransport server, QuicStream stream, ThreadManager thread, int bufferSize) { byte[] receivedData = new byte[bufferSize]; while (!thread.ShouldExit) { int receivedLength; try { receivedLength = stream.Read(receivedData, 0, bufferSize); if (receivedLength == 0) { server.AddEvent(host.VisitorCreateTransportEvent(EventType.Disconnected, null)); break; } else { host.VisitorAddReceivedData(ArrayUtility.SubArray <byte>(receivedData, 0, receivedLength)); } } catch (QuicException ex) { server.AddEvent(new TransportEvent(EventType.Disconnected, null, ex)); break; } } }
private void ReceiveMessage() { while (true) { byte[] msg = _stream.Read(); int leftCursor = Console.CursorLeft; int currentLineCursor = Console.CursorTop; Console.MoveBufferArea(0, currentLineCursor, Console.WindowWidth, 1, 0, currentLineCursor + 1); Console.SetCursorPosition(0, currentLineCursor); Console.Write(new string(' ', Console.WindowWidth)); Console.SetCursorPosition(0, currentLineCursor); Console.WriteLine(System.Text.Encoding.UTF8.GetString(msg)); Console.SetCursorPosition(leftCursor, currentLineCursor + 1); } }