Пример #1
0
        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));
            }
        }
Пример #2
0
        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));
        }
Пример #3
0
        public void TestParse(string raw, RawMessage expected)
        {
            var actual = RawMessage.Parse(raw);

            Assert.Equal(expected, actual);
        }