示例#1
0
        protected override void HandleMessage(IChannelHandlerContext ctx, MessageEvent e)
        {
            var msg = (Message) e.Message;
            string contentType = msg.Headers["Content-Type"];

            var reader = new StreamReader(msg.Body);
            string body = reader.ReadToEnd();
            msg.Body.Position = 0;

            switch (contentType)
            {
                case "auth/request":
                    SendCommand("auth", _password);
                    break;
                case "command/reply":
                    {
                        Command cmd;
                        if (!_commands.TryPop(out cmd))
                            throw new InvalidOperationException(
                                "Failed to find a command for the recieved command/reply");
                        OnCommand(cmd, msg);
                    }

                    break;
                case "text/event-plain":
                    ParseEvent(msg.Body);
                    break;
                default:
                    break;
            }
        }
 /// <summary>
 /// A message have been received from the channel
 /// </summary>
 /// <param name="ctx">Channel context</param>
 /// <param name="e">Message information</param>
 protected abstract void HandleMessage(IChannelHandlerContext ctx, MessageEvent e);
示例#3
0
 /// <summary>
 /// A message have been received from the channel
 /// </summary>
 /// <param name="ctx">Channel context</param>
 /// <param name="e">Message information</param>
 protected override void HandleMessage(IChannelHandlerContext ctx, MessageEvent e)
 {
 }