Exemplo n.º 1
0
        public static MqMessage Parse(byte header, uint len, MemoryStream stream)
        {
            MqMessage msg = null;

            switch ((MessageType)((header & 0xf0) >> 4))
            {
            case MessageType.CONNECT:
                msg = new MqConnect(header, len, stream);
                break;

            case MessageType.CONNACK:
                msg = new MqConnack(header, len, stream);
                break;

            case MessageType.DISCONNECT:
                msg = new MqDisconnect(header, len, stream);
                break;

            case MessageType.PINGREQ:
                msg = new MqPingReq(header, len, stream);
                break;

            case MessageType.PINGRESP:
                msg = new MqPingResp(header, len, stream);
                break;

            case MessageType.PUBLISH:
                msg = new MqPublish(header, len, stream);
                break;

            case MessageType.SUBSCRIBE:
                msg = new MqSubscribe(header, len, stream);
                break;

            case MessageType.SUBACK:
                msg = new MqSuback(header, len, stream);
                break;

            case MessageType.UNSUBSCRIBE:
                msg = new MqUnsubscribe(header, len, stream);
                break;

            case MessageType.UNSUBACK:
                msg = new MqUnsuback(header, len, stream);
                break;

            case MessageType.PUBACK:
            case MessageType.PUBCOMP:
            case MessageType.PUBREC:
            case MessageType.PUBREL:
                msg = new MqMsgAck(header, len, stream);
                break;
            }
            return(msg);
        }
Exemplo n.º 2
0
 public static MqMessage Parse(byte header, uint len, MemoryStream stream) {
   MqMessage msg=null;
   switch((MessageType)((header & 0xf0) >> 4)) {
   case MessageType.CONNECT:
     msg=new MqConnect(header, len, stream);
     break;
   case MessageType.CONNACK:
     msg=new MqConnack(header, len, stream);
     break;
   case MessageType.DISCONNECT:
     msg=new MqDisconnect(header, len, stream);
     break;
   case MessageType.PINGREQ:
     msg=new MqPingReq(header, len, stream);
     break;
   case MessageType.PINGRESP:
     msg=new MqPingResp(header, len, stream);
     break;
   case MessageType.PUBLISH:
     msg=new MqPublish(header, len, stream);
     break;
   case MessageType.SUBSCRIBE:
     msg=new MqSubscribe(header, len, stream);
     break;
   case MessageType.SUBACK:
     msg=new MqSuback(header, len, stream);
     break;
   case MessageType.UNSUBSCRIBE:
     msg=new MqUnsubscribe(header, len, stream);
     break;
   case MessageType.UNSUBACK:
     msg=new MqUnsuback(header, len, stream);
     break;
     case MessageType.PUBACK:
     case MessageType.PUBCOMP:
     case MessageType.PUBREC:
     case MessageType.PUBREL:
       msg=new MqMsgAck(header, len, stream);
       break;
   }
   return msg;
 }