private void ApplyQos(TopicQos defaultTopicQos, AdapterTopicQos adapterRequiredQos) { if (defaultTopicQos == null) { throw new ArgumentNullException("defaultTopicQos"); } if (adapterRequiredQos == null) { throw new ArgumentNullException("adapterRequiredQos"); } defaultTopicQos.Durability.Kind = adapterRequiredQos.PersistenceType.ConvertPersistence(); defaultTopicQos.Reliability.Kind = adapterRequiredQos.MessageReliabilityType.ConvertReliability(); }
public Topic(string topicName, AdapterTopicQos requiredTopicQoS, TypeSupport clientTypeSupport) { if (clientTypeSupport == null) { throw new ArgumentNullException("clientTypeSupport"); } string domain = null; // just using the default partition, named after the topic name TopicName = topicName; TopicType = typeof(T).Name; // Create a DomainParticipantFactory and a DomainParticipant RegisterDomain(this, domain); ErrorHandler.CheckHandle(Participant, "DDS.DomainParticipantFactory.CreateParticipant"); // Register the required datatype. typeSupport = new TopicTypeSupport(clientTypeSupport); ReturnCode status = typeSupport.RegisterType(Participant, topicName); ErrorHandler.CheckStatus(status, "Topic.TopicMessageTypeSupport.RegisterType"); TopicQos topicQos = null; Participant.GetDefaultTopicQos(ref topicQos); ApplyQos(topicQos, requiredTopicQoS); TopicQos = topicQos; TopicMessageTopic = Participant.CreateTopic(topicName, topicName, topicQos); Participant.SetDefaultTopicQos(topicQos); if (TopicMessageTopic == null) { throw new Exception("QoS for topic " + TopicName + " FAILED!, please check QoS!"); } }