コード例 #1
0
ファイル: MqMessages.cs プロジェクト: enviriot/EnviriotSW
        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);
        }
コード例 #2
0
ファイル: MqMessages.cs プロジェクト: giapdangle/X13.Host
 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;
 }