예제 #1
0
 public void SendRawMessage(string rawMessage, params object[] formatArgs)
 {
     rawMessage = String.Format(rawMessage, formatArgs);
     IRawMessage message = new RawMessage
     {
         Text = rawMessage,
         Direction = RawMessageDirection.Sent
     };
     base.Send(message);
 }
예제 #2
0
        private void RecievedMessage(IAsyncResult asyncResult)
        {
            int readState;
            NetworkStream networkStream = base.GetStream();
            if (networkStream.CanRead)
            {
                readState = networkStream.EndRead(asyncResult);

                if (readState == 0)
                {
                    OnDisconnected(new EventArgs());
                }

                byte[] buffer = asyncResult.AsyncState as byte[];
                IRawMessage message = new RawMessage { Text = this.Encoding.GetString(buffer), Direction = RawMessageDirection.Received };
                OnRecieved(new RawMessageEventArgs { Message = message, Result = asyncResult });
                networkStream.BeginRead(buffer, 0, buffer.Length, RecievedMessage, buffer);
            }
        }