Esempio n. 1
0
 public void Subscribe(MqSite ms)
 {
     if (status == Status.Connected)
     {
         var msg = new MqSubscribe();
         msg.Add(ms.remotePath, QoS.AtMostOnce);
         Send(msg);
     }
 }
Esempio 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);
        }
Esempio n. 3
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;
 }
Esempio n. 4
0
 public void Subscribe(string topic, QoS sQoS) {
   MqSubscribe msg=new MqSubscribe();
   msg.Add(topic, sQoS);
   Send(msg);
 }