/// <summary> /// /// </summary> /// <param name="head"></param> /// <param name="byts"></param> public override void ReadBytes(byte[] byts) { MyHead = CMPPMsgHeader.Read(byts); this.Status = ReverseByteOrder.ReverseBytes(BitConverter.ToUInt32(byts, 12)); this.AuthenticatorISMG = BitConverter.ToString(byts, 16, 16).Replace("-", ""); Version = byts[32]; }
public CMPP_DELIVER_RESP(uint sequenceId, ulong msgId, uint result) { BodyLength = 12; Msg_Id = msgId; Result = result; MyHead = new CMPPMsgHeader(BodyLength, Command_Id.CMPP_DELIVER_RESP, sequenceId); }
/// <summary> /// /// </summary> /// <param name="spId"></param> /// <param name="pwd"></param> public CMPP_CONNECT(string spId, string pwd) { BodyLength = 27; SP_ID = spId; _pwd = pwd; MyHead = new CMPPMsgHeader(BodyLength, Command_Id.CMPP_CONNECT); }
public static CMPPMsgHeader Read(byte[] byts) { if (byts.Length >= 12) { CMPPMsgHeader head = new CMPPMsgHeader(); head.Total_Length = ReverseByteOrder.ReverseBytes(BitConverter.ToUInt32(byts, 0)); head.Command_Id = (Command_Id)ReverseByteOrder.ReverseBytes(BitConverter.ToUInt32(byts, 4)); head.Sequence_Id = ReverseByteOrder.ReverseBytes(BitConverter.ToUInt32(byts, 8)); return(head); } return(null); }
/// <summary> /// /// </summary> /// <param name="service_Id">业务代码</param> /// <param name="sp_Id">sp编号</param> /// <param name="sp_Number">接入号</param> /// <param name="tel">电话</param> /// <param name="content">信息</param> public CMPP_SUBMIT(string service_Id, string sp_Id, string sp_Number, string tel, string content) { Service_Id = service_Id; Msg_src = sp_Id; Src_Id = sp_Number; Dest_terminal_Id = tel; Msg_Content = content; _contentByts = Tools.GetUSCBytes(content); Msg_Length = Convert.ToByte(_contentByts.Length); // BodyLength = 183U + Msg_Length; // MyHead = new CMPPMsgHeader(BodyLength, Command_Id.CMPP_SUBMIT); }
public override void ReadBytes(byte[] byts) { MyHead = CMPPMsgHeader.Read(byts); Msg_Id = ReverseByteOrder.ReverseBytes(BitConverter.ToUInt64(byts, 12)); Dest_Id = Tools.BytesToString(byts, 20, 21); Service_Id = Tools.BytesToString(byts, 41, 10); TP_pid = byts[51]; TP_udhi = byts[52]; Msg_Fmt = byts[53]; Src_terminal_Id = Tools.BytesToString(byts, 54, 32); Src_terminal_type = byts[86]; Registered_Delivery = byts[87]; Msg_Length = byts[88]; Msg_Content = new byte[Msg_Length]; Buffer.BlockCopy(byts, 89, Msg_Content, 0, Msg_Length); }
public override void ReadBytes(byte[] byts) { MyHead = CMPPMsgHeader.Read(byts); Msg_Id = ReverseByteOrder.ReverseBytes(BitConverter.ToUInt64(byts, 12)); Result = (DeliverResult)ReverseByteOrder.ReverseBytes(BitConverter.ToUInt32(byts, 20)); }
public CMPP_SUBMIT_RESP(uint sequenceId) { BodyLength = 12; MyHead = new CMPPMsgHeader(BodyLength, Command_Id.CMPP_SUBMIT_RESP, sequenceId); }
public CMPP_TERMINATE_RESP(uint sequenceId) { MyHead = new CMPPMsgHeader(0, Command_Id.CMPP_TERMINATERESP, sequenceId); }
/// <summary> /// /// </summary> public CMPP_CONNECT_RESP(uint sequenceId) { BodyLength = 33; MyHead = new CMPPMsgHeader(BodyLength, Command_Id.CMPP_CONNECT_RESP, sequenceId); }
public CMPP_ACTIVE_TEST() { MyHead = new CMPPMsgHeader(0, Command_Id.CMPP_ACTIVE_TEST); }
public CMPP_ACTIVE_TEST(uint sequenceId) { MyHead = new CMPPMsgHeader(0, Command_Id.CMPP_ACTIVE_TEST, sequenceId); }
public CMPP_TERMINATE() { MyHead = new CMPPMsgHeader(0, Command_Id.CMPP_TERMINATE); }
public virtual void ReadBytes(byte[] byts) { MyHead = CMPPMsgHeader.Read(byts); }
public CMPP_DELIVER(uint sequenceId) { MyHead = new CMPPMsgHeader(0, Command_Id.CMPP_DELIVER, sequenceId); }
/// <summary> /// /// </summary> /// <param name="sequenceId"></param> public CMPP_ACTIVE_TEST_RESP(uint sequenceId) { BodyLength = 1; MyHead = new CMPPMsgHeader(BodyLength, Command_Id.CMPP_ACTIVE_TEST_RESP, sequenceId); }
/// <summary> /// 读取失败或无可读数据返回 null /// </summary> /// <returns></returns> private CMPPMsgBody_Base read() { byte[] buffer; try { //判断是否有可用的数据 if (channelStateReady && client_sk != null && client_sk.Available > 0) { buffer = readBuffer(client_sk.GetStream()); } else { return(null);//没有可供读取的数据 } //将读取到的数据构建成对象 CMPPMsgHeader head; //读出头部,判断命令类型 head = CMPPMsgHeader.Read(buffer); //根据指令类型,构建应答对象,对于不处理的指令进行丢弃 CMPPMsgBody_Base data = null; switch (head.Command_Id) { case Command_Id.CMPP_SUBMIT_RESP: data = new CMPP_SUBMIT_RESP(head.Sequence_Id); break; case Command_Id.CMPP_DELIVER: data = new CMPP_DELIVER(head.Sequence_Id); break; case Command_Id.CMPP_ACTIVE_TEST: data = new CMPP_ACTIVE_TEST(head.Sequence_Id); break; case Command_Id.CMPP_ACTIVE_TEST_RESP: data = new CMPP_ACTIVE_TEST_RESP(head.Sequence_Id); break; case Command_Id.CMPP_TERMINATE: data = new CMPP_TERMINATE(head.Sequence_Id); break; case Command_Id.CMPP_TERMINATERESP: data = new CMPP_TERMINATE_RESP(head.Sequence_Id); break; default: break; } if (data != null) { data.ReadBytes(buffer); } return(data); } catch (Exception)//流读取异常 { CloseSoket(); return(null); } }