示例#1
0
        public ReturnCode SetListener(ISubscriberListener listener, StatusKind mask)
        {
            ReturnCode result = ReturnCode.Error;

            if (listener != null)
            {
                Gapi.gapi_subscriberListener gapiListener;
                listenerHelper.Listener = listener;
                listenerHelper.CreateListener(out gapiListener);
                lock (listener)
                {
                    using (SubscriberListenerMarshaler marshaler =
                            new SubscriberListenerMarshaler(ref gapiListener))
                    {
                        result = Gapi.Subscriber.set_listener(
                                GapiPeer,
                                marshaler.GapiPtr,
                                mask);
                    }
                }
            }
            else
            {
                result = Gapi.Subscriber.set_listener(
                        GapiPeer,
                        IntPtr.Zero,
                        mask);
            }

            return result;
        }
示例#2
0
        public ISubscriber CreateSubscriber(SubscriberQos qos, ISubscriberListener listener, StatusKind mask)
        {
            ISubscriber subscriber = null;

            using (OpenSplice.CustomMarshalers.SubscriberQosMarshaler marshaler =
                    new OpenSplice.CustomMarshalers.SubscriberQosMarshaler())
            {
                if (marshaler.CopyIn(qos) == ReturnCode.Ok)
                {
                    if (listener != null)
                    {
                        OpenSplice.Gapi.gapi_subscriberListener gapiListener;
                        SubscriberListenerHelper listenerHelper = new SubscriberListenerHelper();
                        listenerHelper.Listener = listener;
                        listenerHelper.CreateListener(out gapiListener);
                        using (SubscriberListenerMarshaler listenerMarshaler =
                                new SubscriberListenerMarshaler(ref gapiListener))
                        {
                            IntPtr gapiPtr = Gapi.DomainParticipant.create_subscriber(
                                    GapiPeer,
                                    marshaler.GapiPtr,
                                    listenerMarshaler.GapiPtr,
                                    mask);
                            if (gapiPtr != IntPtr.Zero)
                            {
                                subscriber = new Subscriber(gapiPtr, listenerHelper);
                            }
                        }
                    }
                    else
                    {
                        // Invoke the corresponding gapi function.
                        IntPtr gapiPtr = Gapi.DomainParticipant.create_subscriber(
                                GapiPeer,
                                marshaler.GapiPtr,
                                IntPtr.Zero,
                                mask);
                        if (gapiPtr != IntPtr.Zero)
                        {
                            subscriber = new Subscriber(gapiPtr);
                        }
                    }
                }
            }

            if (subscriber != null)
            {
                DomainParticipantQos dpQos = null;
                ReturnCode result = GetQos(ref dpQos);
                if (result == ReturnCode.Ok)
                {
                    if (dpQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        subscriber.Enable();
                    }
                }
            }

            return subscriber;
        }
示例#3
0
        public ISubscriber CreateSubscriber(ISubscriberListener listener, StatusKind mask)
        {
            ISubscriber subscriber = null;

            if (listener != null)
            {
                OpenSplice.Gapi.gapi_subscriberListener gapiListener;
                SubscriberListenerHelper listenerHelper = new SubscriberListenerHelper();
                listenerHelper.Listener = listener;
                listenerHelper.CreateListener(out gapiListener);
                using (SubscriberListenerMarshaler listenerMarshaler =
                        new SubscriberListenerMarshaler(ref gapiListener))
                {
                    IntPtr gapiPtr = Gapi.DomainParticipant.create_subscriber(
                            GapiPeer,
                            Gapi.NativeConstants.GapiSubscriberQosDefault,
                            listenerMarshaler.GapiPtr,
                            mask);
                    if (gapiPtr != IntPtr.Zero)
                    {
                        subscriber = new Subscriber(gapiPtr, listenerHelper);
                    }
                }
            }
            else
            {
                IntPtr gapiPtr = Gapi.DomainParticipant.create_subscriber(
                            GapiPeer,
                            Gapi.NativeConstants.GapiSubscriberQosDefault,
                            IntPtr.Zero,
                            mask);
                if (gapiPtr != IntPtr.Zero)
                {
                    subscriber = new Subscriber(gapiPtr);
                }
            }

            if (subscriber != null)
            {
                DomainParticipantQos dpQos = null;
                ReturnCode result = GetQos(ref dpQos);
                if (result == ReturnCode.Ok)
                {
                    if (dpQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        subscriber.Enable();
                    }
                }
            }

            return subscriber;
        }