internal void UnBind() {
   if (TcpConnection.Connected) {
     var requestPdu = new SmppUnBindReq();
     var asyncObject = new SmppAsyncObject();
     SendReqPdu(requestPdu, ref asyncObject);
     TcpConnection.Disconnect();
   }
   LastBindRes = null;
 }
 public SmppAsyncBindResEventArgs(SmppBindRes ResponsePdu) {
   _ResponsePdu = ResponsePdu;
 }
 void TcpConnection_OpenConnection(Exception e) {
   SmppBindRes responsePdu = null;
   Exception processException = null;
   lock (this) {
     try {
       if ((e == null) && TcpConnection.Connected) {
         var asyncObject = PendingBind[0] as SmppAsyncObject;
         SendReqPdu(asyncObject.Request, ref asyncObject);
         responsePdu = new SmppBindRes(asyncObject.PduRes);
         if (responsePdu.Header.CommandStatus != 0)
           TcpConnection.Disconnect();
         else {
           LastBindRes = responsePdu;
           PendingResponse.Clear();
           ConnectionSuccess = true;
         }
       } else
         processException = e;
     } catch (Exception exception2) {
       processException = exception2;
     }
     Binding = false;
     PendingBindResTrigger(responsePdu, processException);
   }
 }
 void PendingBindResTrigger(SmppBindRes ResponsePdu, Exception ProcessException) {
   foreach (SmppAsyncObject obj2 in PendingBind) {
     var e = new SmppAsyncBindResEventArgs();
     e._State = obj2.State;
     e._ProcessException = ProcessException;
     e._RequestPdu = obj2.Request as SmppBindReq;
     e._ResponsePdu = ResponsePdu;
     var callback = obj2.Callback as SmppBindResHandler;
     callback(this, e);
   }
   PendingBind.Clear();
 }
 internal SmppBindRes Bind() {
   SmppBindRes res = null;
   SmppBindReq requestPdu = null;
   lock (this) {
     try {
       if (Connected)
         throw new Exception("You must disconnect before connect again", new SocketException(0x186a1));
       TcpConnection.RemoteHost = Settings.RemoteHost;
       TcpConnection.RemotePort = Settings.RemotePort;
       TcpConnection.LocalHost = Settings.LocalHost;
       TcpConnection.LocalPort = Settings.LocalPort;
       TcpConnection.BufferSize = Settings.SocketBufferSize;
       ConnectionSuccess = false;
       TcpConnection.Connect();
     } catch (Exception exception) {
       _LastException = exception;
       res = new SmppBindRes(new SmppHeader(Settings.ConnectionMode.Value, GetSequenceNumber()));
       res.Header.CommandStatus = 0x15f95;
       return res;
     }
     requestPdu = new SmppBindReq(Settings.ConnectionMode.Value, GetSequenceNumber(), Settings.BindParams);
     var asyncObject = new SmppAsyncObject();
     SendReqPdu(requestPdu, ref asyncObject);
     res = new SmppBindRes(asyncObject.PduRes);
     if (res.Header.CommandStatus != 0) {
       TcpConnection.Disconnect();
       return res;
     }
     PendingResponse.Clear();
     ConnectionSuccess = true;
   }
   return res;
 }
 internal void BeginUnBind() {
   if (TcpConnection.Connected) {
     SendResPdu(new SmppUnBindReq().ToByteArray());
     TcpConnection.Disconnect();
   }
   LastBindRes = null;
 }
Example #7
0
 public int BindRes(Guid ConnGuid, SmppBindRes ResponsePdu) {
   return TcpServer.Send(ConnGuid, ResponsePdu.ToByteArray());
 }