public byte[] GetBytes() { //Approximate buffer required; int capacity = 4 + vAddress == null ? 1 : vAddress.Length; ByteBuffer buffer = new ByteBuffer(capacity); buffer.Append((byte)vTon); buffer.Append((byte)vNpi); buffer.Append(PDU.EncodeCString(vAddress)); return(buffer.ToBytes()); }
internal static SmppAddress Parse(ByteBuffer buffer) { //We require at least 3 bytes for SMPPAddress instance to be craeted if (buffer.Length < 3) { throw new NotEnoughBytesException("SMPPAddress requires at least 3 bytes"); } TypeOfNumber ton = (TypeOfNumber)PDU.GetByte(buffer); NumberingPlanIndicator npi = (NumberingPlanIndicator)PDU.GetByte(buffer); string address = PDU.DecodeCString(buffer); return(new SmppAddress(ton, npi, address)); }
public void Send(PDU pdu) { if (pdu == null) { throw new ArgumentNullException("pdu"); } byte[] bytesToSend = pdu.GetBytes(); vTcpIpSession.Send(bytesToSend); }
public PDUErrorEventArgs(PDUException exception, byte[] byteDump, PDUHeader header, PDU pdu) : this(exception,byteDump,header) { vPdu = pdu; }
private void RaisePduErrorEvent(PDUException exception, byte[] byteDump, PDUHeader header, PDU pdu) { if (PDUError == null) { return; } PDUErrorEventArgs e = new PDUErrorEventArgs(exception, byteDump, header, pdu); foreach (EventHandler<PDUErrorEventArgs> del in PDUError.GetInvocationList()) { del.BeginInvoke(this, e, AsyncCallBackRaisePduErrorEvent, del); } }