internal BodyPdu(ByteBuilder bb, ref int StartPosition) { _ServiceType = SmppServiceType.Default; _SourceAddress = string.Empty; _DestinationAddress = string.Empty; _EsmClass = new BitBuilder(); _RegisteredDelivery = new BitBuilder(); _ShortMessage = new SmppString(); _ServiceType = SmppServiceType.FromValue( SmppDataCoding.BaseEncoding.GetString(bb.ReadBytesUntil(ref StartPosition, 0))); _SourceAddressTon = bb.ReadByte(ref StartPosition); _SourceAddressNpi = bb.ReadByte(ref StartPosition); _SourceAddress = SmppDataCoding.BaseEncoding.GetString(bb.ReadBytesUntil(ref StartPosition, 0)); _DestinationAddressTon = bb.ReadByte(ref StartPosition); _DestinationAddressNpi = bb.ReadByte(ref StartPosition); _DestinationAddress = SmppDataCoding.BaseEncoding.GetString(bb.ReadBytesUntil(ref StartPosition, 0)); _EsmClass.Value = bb.ReadByte(ref StartPosition); _ProtocolId = bb.ReadByte(ref StartPosition); _PriorityFlag = bb.ReadByte(ref StartPosition); _ScheduleDeliveryTime = new SmppDateTime(SmppDataCoding.BaseEncoding.GetString(bb.ReadBytesUntil(ref StartPosition, 0))); _ValidityPeriod = new SmppDateTime(SmppDataCoding.BaseEncoding.GetString(bb.ReadBytesUntil(ref StartPosition, 0))); _RegisteredDelivery.Value = bb.ReadByte(ref StartPosition); _ReplaceIfPresent = bb.ReadByte(ref StartPosition); _ShortMessage.DataCoding = SmppDataCoding.FromValue(bb.ReadByte(ref StartPosition)); _SmDefaultMessageId = bb.ReadByte(ref StartPosition); byte length = bb.ReadByte(ref StartPosition); _ShortMessage.Value = bb.ReadBytes(ref StartPosition, length); }
private bool SendWapServiceIndication(TransactionMessage transactionmessage) { bool sendSuccess = false; SmppSubmitSmReq.BodyPdu ReqSubmit_Sm = new SmppSubmitSmReq.BodyPdu(); SmppSubmitSmReq.BodyPdu submitRequest = new Devshock.Protocol.SmppPdu.SmppSubmitSmReq.BodyPdu(); //submitRequest.RegisteredDelivery = new Devshock.Common.BitBuilder(); //submitRequest.RegisteredDelivery.Value = 1; PushMessage message = createPushMessage(transactionmessage.ResponseMessage); ReqSubmit_Sm.EsmClass = new Devshock.Common.BitBuilder(); ReqSubmit_Sm.EsmClass.Value = 0x40; ReqSubmit_Sm.ShortMessage.SetValue(message.GetSMSBytes(), SmppDataCoding.FromValue(0xF5)); //// setup the sending params ////submitRequest.Data_Coding = 0; //submitRequest.DestinationAddressNpi = m_smppConfigInfo.m_destNPI; //submitRequest.DestinationAddressTon = m_smppConfigInfo.m_destTON; //submitRequest.SourceAddressNpi = m_smppConfigInfo.m_addrNPI; //submitRequest.SourceAddressTon = m_smppConfigInfo.m_addrTON; //submitRequest.DestinationAddress = smsMessageInfo.m_destAddress; //submitRequest.SourceAddress = smsMessageInfo.m_srcAddress; //return sendSuccess; //bool sendSuccess = false; // SmppSubmitSmReq.BodyPdu ReqSubmit_Sm = new SmppSubmitSmReq.BodyPdu(); SmppSubmitSmRes ResSubmit_Sm = null; if (smppconn.Connected == false) { this.Connect(); if (ResBind.Header.CommandStatus == 0) { try { ReqSubmit_Sm = new SmppSubmitSmReq.BodyPdu(); //SmppSubmitSmRes ResSubmit_Sm; // ReqSubmit_Sm.EsmClass = new BitBuilder((byte)0x40); // UHDI this should always be 0x40 // ReqSubmit_Sm.ShortMessage.DataCoding = SmppDataCoding.FromValue((byte)0x00); //if it is unicode use 0x08 like for arabic or other unicode lang. ReqSubmit_Sm.SourceAddressTon = new BitBuilder(tProtocol.AddrTON).Value; ReqSubmit_Sm.SourceAddressNpi = new BitBuilder(tProtocol.AddrNPI).Value; ReqSubmit_Sm.DestinationAddressTon = new BitBuilder(tProtocol.DestTON).Value; ReqSubmit_Sm.DestinationAddressNpi = new BitBuilder(tProtocol.DestNPI).Value; ReqSubmit_Sm.RegisteredDelivery = new BitBuilder(1); ReqSubmit_Sm.DestinationAddress = transactionmessage.Msisdn; ReqSubmit_Sm.SourceAddress = transactionmessage.ShortCode; // //ReqSubmit_Sm.ShortMessage.SetValue(transactionmessage.ResponseMessage); ReqSubmit_Sm.ShortMessage.SetValue(message.GetSMSBytes(), SmppDataCoding.FromValue(0xF5)); if (smppconn.Connected == true) { try { ResSubmit_Sm = smppconn.SubmitSm(new SmppSubmitSmReq(ReqSubmit_Sm)); // No copy to logger //logger.Error(tProtocol.NetworkID + ":" + tProtocol.OperatorID + ": EnquireLink SequenceNumber: " + enquireLinkResponse.Header.SequenceNumber.ToString() + "\n"); //logger.Info( transactionmessage.NetworkID + ":" + transactionmessage.OperatorID + " Send Message to: " + Transmitter Client Connected Successfully\n"); logger.Info(transactionmessage.NetworkID + ":" + transactionmessage.OperatorID + ":Out Message: Destination [" + transactionmessage.Msisdn + "] Source [" + transactionmessage.ShortCode + "]Body [" + transactionmessage.ResponseMessage + "]\n"); //Console.WriteLine("|" + + ":" + + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ": Sent Message to: " + transactionmessage.Msisdn + " : Message: " + transactionmessage.ResponseMessage); } catch (Exception ex01) { logger.Error(transactionmessage.NetworkID + ":" + transactionmessage.OperatorID + ":Out Message Destination[" + transactionmessage.Msisdn + "] Source [" + transactionmessage.ShortCode + "]Error [" + ex01.Message + "]\n"); } //ResSubmit_Sm = smppconn.SubmitSm(new SmppSubmitSmReq(ReqSubmit_Sm)); } else { return(sendSuccess); } // if (ResSubmit_Sm.Header.CommandStatus == 0) try { if (ResSubmit_Sm.Header.CommandStatus == 0) { sendSuccess = true; } } catch (Exception ex02) { logger.Error(transactionmessage.NetworkID + ":" + transactionmessage.OperatorID + ":Out Message Destination[" + transactionmessage.Msisdn + "] Source [" + transactionmessage.ShortCode + "]Error [" + ex02.Message + "]\n"); } } catch (Exception exception) { logger.Error(exception.Message + "\n"); } } } else { try { ReqSubmit_Sm.DestinationAddressTon = Convert.ToByte(tProtocol.DestTON); ReqSubmit_Sm.DestinationAddressNpi = Convert.ToByte(tProtocol.DestNPI); ReqSubmit_Sm.SourceAddressNpi = Convert.ToByte(tProtocol.AddrNPI); ReqSubmit_Sm.SourceAddressTon = Convert.ToByte(tProtocol.AddrTON); ReqSubmit_Sm.RegisteredDelivery = new BitBuilder(1); ReqSubmit_Sm.DestinationAddress = transactionmessage.Msisdn; //ReqSubmit_Sm.ShortMessage.SetValue(transactionmessage.ResponseMessage); // = mySmppClient.SetShortMessage(ReqSubmit_Sm.Data_Coding, m_Message); ReqSubmit_Sm.ShortMessage.SetValue(message.GetSMSBytes(), SmppDataCoding.FromValue(0xF5)); ReqSubmit_Sm.SourceAddress = transactionmessage.ShortCode; if (smppconn.Connected == true) { try { ResSubmit_Sm = smppconn.SubmitSm(new SmppSubmitSmReq(ReqSubmit_Sm)); // No copy to logger logger.Info(transactionmessage.NetworkID + ":" + transactionmessage.OperatorID + ":Out Message: Destination [" + transactionmessage.Msisdn + "] Source [" + transactionmessage.ShortCode + "]Body [" + transactionmessage.ResponseMessage + "]\n"); } catch (Exception ex03) { logger.Error(transactionmessage.NetworkID + ":" + transactionmessage.OperatorID + ":Out Message Destination[" + transactionmessage.Msisdn + "] Source [" + transactionmessage.ShortCode + "]Error [" + ex03.Message + "]\n"); } } else { return(sendSuccess); } //ResSubmit_Sm = smppconn.SubmitSm(new SmppSubmitSmReq(ReqSubmit_Sm)); try { if (ResSubmit_Sm.Header.CommandStatus == 0) { sendSuccess = true; } } catch (Exception ex04) { logger.Error(transactionmessage.NetworkID + ":" + transactionmessage.OperatorID + ":Out Message Destination[" + transactionmessage.Msisdn + "] Source [" + transactionmessage.ShortCode + "]Error [" + ex04.Message + "]\n"); } } catch (SmppException exception) { logger.Error(exception.Message + "\n"); } } return(sendSuccess); }