X13.Periphery.MsMessage.Parse C# (CSharp) 메소드

Parse() 공개 정적인 메소드

public static Parse ( byte buf, int start, int end ) : MsMessage
buf byte
start int
end int
리턴 MsMessage
    public static MsMessage Parse(byte[] buf, int start, int end) {
      if(start+1>end) {
        return null;
      }
      var msgTyp=(MsMessageType)(buf[start+0]>1?buf[start+1]:buf[start+3]);
      try {
        switch(msgTyp) {
        case MsMessageType.ADVERTISE:
          return new MsAdvertise(buf, start, end);
        case MsMessageType.SEARCHGW:
          return new MsSearchGW(buf, start, end);
        case MsMessageType.GWINFO:
          return new MsGwInfo(buf, start, end);
        case MsMessageType.CONNECT:
          return new MsConnect(buf, start, end);
        case MsMessageType.WILLTOPIC:
          return new MsWillTopic(buf, start, end);
        case MsMessageType.WILLMSG:
          return new MsWillMsg(buf, start, end);
        case MsMessageType.SUBSCRIBE:
          return new MsSubscribe(buf, start, end);
        case MsMessageType.REGISTER:
          return new MsRegister(buf, start, end);
        case MsMessageType.REGACK:
          return new MsRegAck(buf, start, end);
        case MsMessageType.PUBLISH:
          return new MsPublish(buf, start, end);
        case MsMessageType.PUBACK:
          return new MsPubAck(buf, start, end);
        case MsMessageType.PINGREQ:
          return new MsPingReq(buf, start, end);
        case MsMessageType.DISCONNECT:
          return new MsDisconnect(buf, start, end);
        case MsMessageType.DHCP_REQ:
          return new MsDhcpReq(buf, start, end);
        case MsMessageType.EncapsulatedMessage:
          return new MsForward(buf, start, end);
        }
      }
      catch(Exception) {
      }
      return null;
    }
    protected static UTF8Encoding enc = new UTF8Encoding();

Usage Example

예제 #1
0
 public MsForward(byte[] buf, int start, int end)
     : base(buf, start, end)
 {
     addr = new byte[_length - 3];
     Buffer.BlockCopy(buf, start + 3, addr, 0, _length - 3);
     msg = MsMessage.Parse(buf, start + _length, end);
 }
All Usage Examples Of X13.Periphery.MsMessage::Parse