public ReturnCode SetListener(ITopicListener listener, StatusKind mask) { ReturnCode result = ReturnCode.Error; Gapi.gapi_topicListener gapiListener; listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); if (listener != null) { lock (listener) { using (TopicListenerMarshaler marshaler = new TopicListenerMarshaler(ref gapiListener)) { result = Gapi.Topic.set_listener( GapiPeer, marshaler.GapiPtr, mask); } } } else { result = Gapi.Topic.set_listener( GapiPeer, IntPtr.Zero, mask); } return(result); }
public ITopic CreateTopic( string topicName, string typeName, TopicQos qos, ITopicListener listener, StatusKind mask) { ITopic topic = null; using (OpenSplice.CustomMarshalers.TopicQosMarshaler marshaler = new OpenSplice.CustomMarshalers.TopicQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { OpenSplice.Gapi.gapi_topicListener gapiListener; TopicListenerHelper listenerHelper = new TopicListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (TopicListenerMarshaler listenerMarshaler = new TopicListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr, listenerHelper); } } } else { // Invoke the corresponding gapi function. IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr); } } } } if (topic != null) { DomainParticipantQos dpQos = null; ReturnCode result = GetQos(ref dpQos); if (result == ReturnCode.Ok) { if (dpQos.EntityFactory.AutoenableCreatedEntities) { topic.Enable(); } } } return topic; }
public ITopic CreateTopic( string topicName, string typeName, ITopicListener listener, StatusKind mask) { ITopic topic = null; if (listener != null) { OpenSplice.Gapi.gapi_topicListener gapiListener; TopicListenerHelper listenerHelper = new TopicListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (TopicListenerMarshaler listenerMarshaler = new TopicListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, Gapi.NativeConstants.GapiTopicQosDefault, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr, listenerHelper); } } } else { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, Gapi.NativeConstants.GapiTopicQosDefault, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr); } } if (topic != null) { DomainParticipantQos dpQos = null; ReturnCode result = GetQos(ref dpQos); if (result == ReturnCode.Ok) { if (dpQos.EntityFactory.AutoenableCreatedEntities) { topic.Enable(); } } } return topic; }
public ITopic CreateTopic( string topicName, string typeName, TopicQos qos, ITopicListener listener, StatusKind mask) { ITopic topic = null; using (OpenSplice.CustomMarshalers.TopicQosMarshaler marshaler = new OpenSplice.CustomMarshalers.TopicQosMarshaler()) { if (marshaler.CopyIn(qos) == ReturnCode.Ok) { if (listener != null) { OpenSplice.Gapi.gapi_topicListener gapiListener; TopicListenerHelper listenerHelper = new TopicListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (TopicListenerMarshaler listenerMarshaler = new TopicListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, marshaler.GapiPtr, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr, listenerHelper); } } } else { // Invoke the corresponding gapi function. IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, marshaler.GapiPtr, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr); } } } } if (topic != null) { DomainParticipantQos dpQos = null; ReturnCode result = GetQos(ref dpQos); if (result == ReturnCode.Ok) { if (dpQos.EntityFactory.AutoenableCreatedEntities) { topic.Enable(); } } } return(topic); }
public ITopic CreateTopic( string topicName, string typeName, ITopicListener listener, StatusKind mask) { ITopic topic = null; if (listener != null) { OpenSplice.Gapi.gapi_topicListener gapiListener; TopicListenerHelper listenerHelper = new TopicListenerHelper(); listenerHelper.Listener = listener; listenerHelper.CreateListener(out gapiListener); using (TopicListenerMarshaler listenerMarshaler = new TopicListenerMarshaler(ref gapiListener)) { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, Gapi.NativeConstants.GapiTopicQosDefault, listenerMarshaler.GapiPtr, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr, listenerHelper); } } } else { IntPtr gapiPtr = Gapi.DomainParticipant.create_topic( GapiPeer, topicName, typeName, Gapi.NativeConstants.GapiTopicQosDefault, IntPtr.Zero, mask); if (gapiPtr != IntPtr.Zero) { topic = new Topic(gapiPtr); } } if (topic != null) { DomainParticipantQos dpQos = null; ReturnCode result = GetQos(ref dpQos); if (result == ReturnCode.Ok) { if (dpQos.EntityFactory.AutoenableCreatedEntities) { topic.Enable(); } } } return(topic); }