示例#1
0
        public void BeginBind(SmppBindResHandler Callback, object State)
        {
            if ((_InternalConnection != null) && _InternalConnection.Connected)
            {
                throw new SmppException("Error Connecting: The connection is already Open.");
            }
            switch (_Settings.Recycling.Method)
            {
            case SmppSettings.RecyclingMethod.Pooling:
                _InternalConnection = SmppPoolManager.GetConnection(_Settings);
                break;

            case SmppSettings.RecyclingMethod.Sharing:
                _InternalConnection = SmppShareManager.GetConnection(_Settings);
                break;

            default:
                _InternalConnection = new SmppInternalConnection(_Settings);
                break;
            }
            SetEvents();
            if ((_InternalConnection.Connected && (_InternalConnection.LastBindRes != null)) &&
                ((_InternalConnection.LastBindRes.Header != null) &&
                 (_InternalConnection.LastBindRes.Header.CommandStatus == 0)))
            {
                Callback(this, new SmppAsyncBindResEventArgs(_InternalConnection.LastBindRes));
            }
            else
            {
                _InternalConnection.BeginBind(Callback, State);
            }
        }
        internal void BeginBind(SmppBindResHandler Callback, object State)
        {
            lock (this) {
                var req  = new SmppBindReq(Settings.ConnectionMode.Value, GetSequenceNumber(), Settings.BindParams);
                var obj2 = new SmppAsyncObject();
                obj2.Callback = Callback;
                obj2.Request  = req;
                obj2.State    = State;
                obj2.Timeout  = Settings.Timeout;
                PendingBind.Add(obj2);
                if (!Connected)
                {
                    if (Binding)
                    {
                        goto Label_0142;
                    }
                    TcpConnection.RemoteHost = Settings.RemoteHost;
                    TcpConnection.RemotePort = Settings.RemotePort;
                    TcpConnection.LocalHost  = Settings.LocalHost;
                    TcpConnection.LocalPort  = Settings.LocalPort;
                    TcpConnection.BufferSize = Settings.SocketBufferSize;
                    ConnectionSuccess        = false;
                    Binding = true;
                    try {
                        ThreadPool.QueueUserWorkItem(AsyncConnect);
                        goto Label_0142;
                    } catch {
                        Binding = false;
                        PendingBind.Remove(obj2);
                        throw;
                    }
                }
                ThreadPool.QueueUserWorkItem(AsyncNotifyConnect);
Label_0142:
                ;
            }
        }
示例#3
0
    public void BeginBind(SmppBindResHandler Callback, object State) {
      if ((_InternalConnection != null) && _InternalConnection.Connected)
        throw new SmppException("Error Connecting: The connection is already Open.");
      switch (_Settings.Recycling.Method) {
        case SmppSettings.RecyclingMethod.Pooling:
          _InternalConnection = SmppPoolManager.GetConnection(_Settings);
          break;

        case SmppSettings.RecyclingMethod.Sharing:
          _InternalConnection = SmppShareManager.GetConnection(_Settings);
          break;

        default:
          _InternalConnection = new SmppInternalConnection(_Settings);
          break;
      }
      SetEvents();
      if ((_InternalConnection.Connected && (_InternalConnection.LastBindRes != null)) &&
          ((_InternalConnection.LastBindRes.Header != null) &&
           (_InternalConnection.LastBindRes.Header.CommandStatus == 0)))
        Callback(this, new SmppAsyncBindResEventArgs(_InternalConnection.LastBindRes));
      else
        _InternalConnection.BeginBind(Callback, State);
    }
示例#4
0
 public void BeginBind(SmppBindResHandler Callback) {
   BeginBind(Callback, null);
 }
示例#5
0
 public void BeginBind(SmppBindResHandler Callback)
 {
     BeginBind(Callback, null);
 }
 internal void BeginBind(SmppBindResHandler Callback, object State) {
   lock (this) {
     var req = new SmppBindReq(Settings.ConnectionMode.Value, GetSequenceNumber(), Settings.BindParams);
     var obj2 = new SmppAsyncObject();
     obj2.Callback = Callback;
     obj2.Request = req;
     obj2.State = State;
     obj2.Timeout = Settings.Timeout;
     PendingBind.Add(obj2);
     if (!Connected) {
       if (Binding)
         goto Label_0142;
       TcpConnection.RemoteHost = Settings.RemoteHost;
       TcpConnection.RemotePort = Settings.RemotePort;
       TcpConnection.LocalHost = Settings.LocalHost;
       TcpConnection.LocalPort = Settings.LocalPort;
       TcpConnection.BufferSize = Settings.SocketBufferSize;
       ConnectionSuccess = false;
       Binding = true;
       try {
         ThreadPool.QueueUserWorkItem(AsyncConnect);
         goto Label_0142;
       } catch {
         Binding = false;
         PendingBind.Remove(obj2);
         throw;
       }
     }
     ThreadPool.QueueUserWorkItem(AsyncNotifyConnect);
     Label_0142:
     ;
   }
 }