Example #1
0
        protected override void OnSocketDataReceived(TCPSocket socket, SocketDataReceivedEventArgs args)
        {
            Message message;
            int pos  = 0;
            byte[] buffer = args.Packet.Buffer;
            byte[] data = new byte[buffer.Length];

            while (pos < args.Packet.Length) {
                buffer.CopyTo(data, pos);
                if (!Message.TryParse(data, out message)) return;
                OnMessageReceived(message);
                pos += message.Length + 1;
            }
            base.OnSocketDataReceived(socket, args);
        }
 protected virtual void OnSocketDataReceived(TCPSocket socket, SocketDataReceivedEventArgs args)
 {
     if (DataReceived != null) DataReceived(socket, args);
 }