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 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 SmppBindEventArgs(Guid ConnGuid, SmppBindReq Pdu)
 {
     _Pdu      = Pdu;
     _ConnGuid = ConnGuid;
 }
示例#4
0
        void ProcessPdu(Guid ConnGuid, ByteBuilder bb)
        {
            var header = new SmppHeader(bb);

            if (bb.Count > 0x10)
            {
                bb.ToArray(0x10, bb.Count - 0x10);
            }
            if (((header.CommandId == 2) || (header.CommandId == 1)) || (header.CommandId == 9))
            {
                try {
                    var pdu = new SmppBindReq(bb);
                    if (OnBindReq != null)
                    {
                        OnBindReq(this, new SmppBindEventArgs(ConnGuid, pdu));
                    }
                } catch {}
            }
            else
            {
                int commandId = header.CommandId;
                if (commandId <= -2147483627)
                {
                    switch (commandId)
                    {
                    case -2147483643: {
                        var res = new SmppDeliverSmRes(bb);
                        if (OnDeliverSmRes != null)
                        {
                            OnDeliverSmRes(this, new SmppDeliverSmResEventArgs(ConnGuid, res));
                        }
                        return;
                    }

                    case -2147483627: {
                        var res2 = new SmppEnquireLinkRes(bb);
                        if (OnEnquireLinkRes != null)
                        {
                            OnEnquireLinkRes(this, new SmppEnquireLinkResEventArgs(ConnGuid, res2));
                            return;
                        }
                        break;
                    }
                    }
                }
                else
                {
                    switch (commandId)
                    {
                    case 3: {
                        var req4 = new SmppQuerySmReq(bb);
                        if (OnQuerySmReq != null)
                        {
                            OnQuerySmReq(this, new SmppQuerySmEventArgs(req4, ConnGuid));
                        }
                        return;
                    }

                    case 4: {
                        var req2 = new SmppSubmitSmReq(bb);
                        if (OnSubmitSmReq != null)
                        {
                            OnSubmitSmReq(this, new SmppSubmitSmEventArgs(ConnGuid, req2));
                        }
                        return;
                    }

                    case 5:
                        return;

                    case 6: {
                        var req5 = new SmppUnBindReq(bb);
                        if (OnUnBindReq != null)
                        {
                            OnUnBindReq(this, new SmppUnBindEventArgs(ConnGuid, req5));
                        }
                        return;
                    }

                    case 0x15: {
                        var req3 = new SmppEnquireLinkReq(bb);
                        if (OnEnquireLinkReq != null)
                        {
                            OnEnquireLinkReq(this, new SmppEnquireLinkEventArgs(ConnGuid, req3));
                        }
                        return;
                    }

                    default:
                        return;
                    }
                }
            }
        }