Exemplo n.º 1
0
        protected void InitializeStub(Guid interfaceID, byte[] MIDL_ProcFormatString, byte[] MIDL_TypeFormatString, string pipe, ushort MajorVerson = 1, ushort MinorVersion = 0)
        {
            this.MIDL_ProcFormatString = MIDL_ProcFormatString;
            this.MIDL_TypeFormatString = MIDL_TypeFormatString;
            PipeName   = pipe;
            procString = GCHandle.Alloc(this.MIDL_ProcFormatString, GCHandleType.Pinned);

            RPC_CLIENT_INTERFACE         clientinterfaceObject = new RPC_CLIENT_INTERFACE(interfaceID, MajorVerson, MinorVersion);
            GENERIC_BINDING_ROUTINE_PAIR bindingObject         = new GENERIC_BINDING_ROUTINE_PAIR();

            // important: keep a reference to avoid CallbakcOnCollectedDelegate Exception
            BindDelegate         = Bind;
            UnbindDelegate       = Unbind;
            bindingObject.Bind   = Marshal.GetFunctionPointerForDelegate((bind)BindDelegate);
            bindingObject.Unbind = Marshal.GetFunctionPointerForDelegate((unbind)UnbindDelegate);

            faultoffsets = GCHandle.Alloc(new COMM_FAULT_OFFSETS()
            {
                CommOffset = -1, FaultOffset = -1
            }, GCHandleType.Pinned);
            clientinterface = GCHandle.Alloc(clientinterfaceObject, GCHandleType.Pinned);
            formatString    = GCHandle.Alloc(MIDL_TypeFormatString, GCHandleType.Pinned);
            bindinghandle   = GCHandle.Alloc(bindingObject, GCHandleType.Pinned);

            MIDL_STUB_DESC stubObject = new MIDL_STUB_DESC(formatString.AddrOfPinnedObject(),
                                                           clientinterface.AddrOfPinnedObject(),
                                                           Marshal.GetFunctionPointerForDelegate(AllocateMemoryDelegate),
                                                           Marshal.GetFunctionPointerForDelegate(FreeMemoryDelegate),
                                                           bindinghandle.AddrOfPinnedObject());

            rpcClientInterface = stubObject.RpcInterfaceInformation;

            stub = GCHandle.Alloc(stubObject, GCHandleType.Pinned);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This processes the unbind event; we always allow this event.
        /// </summary>
        /// <param name="pdu">Protocol Data Unit</param>
        public override void Process(unbind pdu)
        {
            unbind_resp pduOut = new unbind_resp(pdu.SequenceNumber);

            session_.FireEvent(EventType.UnBind, new SmppEventArgs(session_, pdu, pduOut));
            session_.PeerSystemID = "";
            session_.SmppVersion  = 0;
            session_.CurrentState = new SmscOpenSessionState(session_);
            session_.SendPdu(pduOut);
            session_.Close();
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method is used to unbind our session synchronously.
        /// </summary>
        /// <returns>Unbind response PDU</returns>
        public unbind_resp UnBind()
        {
            unbind         pdu      = new unbind();
            unbind_resp    response = null;
            PduSyncronizer sync     = AddWaitingPdu(pdu);

            if (sync != null)
            {
                if (IsBound && SendPdu(pdu))
                {
                    if (sync.WaitForResponse())
                    {
                        response = sync.PduResponse as unbind_resp;
                        if (response == null)
                        {
                            response = new unbind_resp(pdu.SequenceNumber, sync.PduResponse.Status);
                        }
                    }
                    else
                    {
                        response = new unbind_resp(pdu.SequenceNumber, StatusCodes.ESME_RINVEXPIRY);
                    }
                }
                else
                {
                    response = new unbind_resp(pdu.SequenceNumber, StatusCodes.ESME_RINVBNDSTS);
                }
                FindAndRemoveWaitingPdu(pdu.SequenceNumber);
            }
            else
            {
                response = new unbind_resp(pdu.SequenceNumber, StatusCodes.ESME_RMSGQFUL);
            }

            return(response);
        }
Exemplo n.º 4
0
 /// <summary>
 /// This processes the unbind PDU
 /// </summary>
 /// <param name="pdu">Protocol Data Unit being processed</param>
 public virtual void Process(unbind pdu)
 {
     throw new InvalidSmppStateException("Session is not in the proper state for an unbind operation.");
 }
Exemplo n.º 5
0
 /// <summary>
 /// This method processes the unbind pdu if SMSC unbinds from ESME.
 /// </summary>
 /// <param name="pdu">Protocol Data Unit being processed</param>
 public override void Process(unbind pdu)
 {
     this.session.SendPdu(new unbind_resp(pdu.SequenceNumber));
     this.session.CurrentState = new EsmeConnectedSessionState(this.session);
     this.session.FireEvent(EventType.UnBound, new SmppEventArgs(this.session));
 }