Esempio n. 1
0
 public MsMessage(MsMessageType type) {
   MsgTyp=type;
   _length=2;
   switch(MsgTyp) {
   case MsMessageType.WILLMSGREQ:
   case MsMessageType.WILLTOPICREQ:
     this.IsRequest=true;
     break;
   }
 }
Esempio n. 2
0
 protected MsMessage(byte[] buf) {
   if(buf[0]>1) {
     _length=buf[0];
   } else {
     _length=(ushort)((buf[1]<<8) | (buf[2]));
   }
   if(buf.Length!=_length) {
     throw new ArgumentException("length is not correct");
   }
   MsgTyp=(MsMessageType)(buf[0]>1?buf[1]:buf[3]);
 }
Esempio n. 3
0
 public MsMessage(MsMessageType type)
 {
     MsgTyp  = type;
     _length = 2;
     switch (MsgTyp)
     {
     case MsMessageType.WILLMSGREQ:
     case MsMessageType.WILLTOPICREQ:
         this.IsRequest = true;
         this.tryCnt    = 3;
         break;
     }
     _sendBuf = null;
 }
Esempio n. 4
0
 protected MsMessage(byte[] buf, int start, int end)
 {
     if (buf[start + 0] > 1)
     {
         _length = buf[start + 0];
     }
     else
     {
         _length = (ushort)((buf[start + 1] << 8) | (buf[start + 2]));
     }
     if (end - start < _length)
     {
         throw new ArgumentException("length is too small");
     }
     MsgTyp   = (MsMessageType)(buf[start + 0] > 1?buf[start + 1]:buf[start + 3]);
     _sendBuf = null;
 }
Esempio n. 5
0
 protected MsMessage(byte[] buf, int start, int end) {
   if(buf[start+0]>1) {
     _length=buf[start+0];
   } else {
     _length=(ushort)((buf[start+1]<<8) | (buf[start+2]));
   }
   if(end-start<_length) {
     throw new ArgumentException("length is too small");
   }
   MsgTyp=(MsMessageType)(buf[start+0]>1?buf[start+1]:buf[start+3]);
   _sendBuf=null;
 }
Esempio n. 6
0
    private void Stat(bool send, MsMessageType t, bool dub=false) {
#if DEBUG
      string n2;
      switch(t) {
      case MsMessageType.CONNECT:
        n2="_Connect";
        break;
      case MsMessageType.GWINFO:
        n2="_Lost";
        break;
      case MsMessageType.PUBLISH:
        if(send) {
          n2=dub?"e_sPublishDup":"d_sPublish";
        } else {
          n2=dub?"b_rPublishDup":"a_rPublish";
        }
        break;
      case MsMessageType.PUBACK:
        n2=send?"c_sPubAck":"f_rPubAck";
        break;
      case MsMessageType.PINGREQ:
        n2="g_PingReq";
        break;
      case MsMessageType.PINGRESP:
        n2="h_PingResp";
        break;
      default:
        n2=send?"o_sOther":"o_rOther";
        break;
      }
      if(Owner==null){
        return;
      }
      string p=string.Concat("/etc/MQTTS/stat/", Owner.name, "/", n2);
      DVar<long> d=Topic.root.Get<long>(p);
      d.saved=false;
      d.value++;
#endif
    }