private async Task ListenAsync() { while (_tcp.Connected) { var line = await _reader.ReadLineAsync(); if (line == null) { break; } var message = RawMessage.Parse(line); MessageReceived?.Invoke(this, new RawMessageReceivedEventArgs(this, message)); } }
private void SocketOnMessage(object sender, MessageEventArgs e) { string line = ""; if (e.IsBinary) { line = Encoding.UTF8.GetString(e.RawData); } else { line = e.Data; } RawMessage message = RawMessage.Parse(line); MessageReceived?.Invoke(this, new RawMessageReceivedEventArgs(this, message)); }
public void TestParse(string raw, RawMessage expected) { var actual = RawMessage.Parse(raw); Assert.Equal(expected, actual); }