Пример #1
0
        public Publisher(Topic topic)
        {
            this.topic = topic;
            this.bytes = new byte[topic.GetSampleMaxSize()];

            this.participant = Participant.GetInstance(topic.GetDomainID(), topic.GetParticipantID());
            //this.inProcessTransport = participant.GetInProcessTransport();
            Init();
        }
Пример #2
0
        public Publisher(Topic topic)
        {
            this.topic = topic;
            this.bytes = new byte[topic.GetSampleMaxSize()];

            this.participant = Participant.GetInstance(topic.GetDomainID(), topic.GetParticipantID());
            this.inProcessTransport = participant.GetInProcessTransport();
            Init();
        }
Пример #3
0
 public ReceiveDataHandler(Topic t, Participant part, IReceiver receiver)
 {
     topic         = t;
     bytes         = new byte[t.GetSampleMaxSize()];
     headerBytes   = new byte[FRAGMENT_HEADER_SIZE];
     participant   = part;
     fragmentSize  = Globals.MAX_SEGMENT_SIZE;
     this.receiver = receiver;
 }
Пример #4
0
 public ReceiveDataHandler(Topic t, Participant part, IReceiver receiver)
 {
     topic = t;
     bytes = new byte[t.GetSampleMaxSize()];
     headerBytes = new byte[FRAGMENT_HEADER_SIZE];
     participant = part;
     fragmentSize = Globals.MAX_SEGMENT_SIZE;
     this.receiver = receiver;
 }
Пример #5
0
        /// Protection is not needed since all calls go through the participant which is synched
        public ReceiveDataHandler GetReceiveDataHandler(Topic top, Participant participant)
        {
            // In the case that we use the same port for several topics, we need to find the receiver for the transport::address::port used
            string key = MakeKey(top);

            if (ReceiveDataHandlers.ContainsKey(key))
            {
                ReceiveDataHandler rdh = ReceiveDataHandlers[key];

                // Check if any of the topics have a sample size larger than MAX_SEGMENT_SIZE
                // This will lead to a problem when using the same port, if samples becomes > MAX_SEGMENT_SIZE
                if ((rdh.GetSampleMaxSize() > Globals.MAX_SEGMENT_SIZE) || (top.GetSampleMaxSize() > Globals.MAX_SEGMENT_SIZE))
                {
                    if (top.GetTransport().Equals(Topic.TRANSPORT_UDP))
                    {
                        Logger.ExceptionLogger.LogMessage("Warning: UDP transport is used with Topics with 'sampleMaxSize' > " + Globals.MAX_SEGMENT_SIZE);
                    }
                    else
                    {
                        Logger.ExceptionLogger.LogMessage("Warning: Same port (" + top.GetPort() + ") is used with Topics with 'sampleMaxSize' > " + Globals.MAX_SEGMENT_SIZE);
                    }
                }
                return(rdh);
            }

            // Get the local interface, doing a translation from subnet if necessary
            string localIF = InetAddress.DoSubnetTranslation(top.GetLocalInterface());

            // Didn't exist, create one if transport is known
            if ((top.GetTransport().Equals(Topic.TRANSPORT_MC)) || (top.GetTransport().Equals(Topic.TRANSPORT_TCP)))
            {
                ReceiveDataHandlers.Add(key,
                                        new ReceiveDataHandler(top, participant, ReceiverFactory.CreateReceiver(top, localIF)));
                return(ReceiveDataHandlers[key]);
            }
            else if (top.GetTransport().Equals(Topic.TRANSPORT_UDP))
            {
                IReceiver rec = ReceiverFactory.CreateReceiver(top, localIF);
                ReceiveDataHandlers.Add(key, new ReceiveDataHandler(top, participant, rec));

                if (key.Equals(Topic.TRANSPORT_UDP))
                {
                    participant.SetUdpTransportInfo(((UdpReceiver)rec).IP, ((UdpReceiver)rec).Port);
                }

                return(ReceiveDataHandlers[key]);
            }
            return(null);
        }
Пример #6
0
        /// Protection is not needed since all calls go through the participant which is synched
        public ReceiveDataHandler GetReceiveDataHandler(Topic top, Participant participant)
        {
            // In the case that we use the same port for several topics, we need to find the receiver for the transport::address::port used
            string key = MakeKey(top);

            if (ReceiveDataHandlers.ContainsKey(key))
            {
                ReceiveDataHandler rdh = ReceiveDataHandlers[key];

                // Check if any of the topics have a sample size larger than MAX_SEGMENT_SIZE
                // This will lead to a problem when using the same port, if samples becomes > MAX_SEGMENT_SIZE
                if ((rdh.GetSampleMaxSize() > Globals.MAX_SEGMENT_SIZE) || (top.GetSampleMaxSize() > Globals.MAX_SEGMENT_SIZE))
                {
                    if (top.GetTransport().Equals(Topic.TRANSPORT_UDP))
                    {
                        Logger.ExceptionLogger.LogMessage("Warning: UDP transport is used with Topics with 'sampleMaxSize' > " + Globals.MAX_SEGMENT_SIZE);
                    }
                    else
                    {
                        Logger.ExceptionLogger.LogMessage("Warning: Same port (" + top.GetPort() + ") is used with Topics with 'sampleMaxSize' > " + Globals.MAX_SEGMENT_SIZE);
                    }
                }
                return rdh;
            }

            // Get the local interface, doing a translation from subnet if necessary
            string localIF = Domain.DoSubnetTranslation(participant.getDomain().GetLocalInterface());

            // Didn't exist, create one if transport is known
            if ( (top.GetTransport().Equals(Topic.TRANSPORT_MC)) || (top.GetTransport().Equals(Topic.TRANSPORT_TCP)) )
            {
                ReceiveDataHandlers.Add(key,
                    new ReceiveDataHandler(top, participant, ReceiverFactory.CreateReceiver(top, localIF)));
                return ReceiveDataHandlers[key];
            }
            else if (top.GetTransport().Equals(Topic.TRANSPORT_UDP))
            {
                IReceiver rec = ReceiverFactory.CreateReceiver(top, localIF);
                ReceiveDataHandlers.Add(key, new ReceiveDataHandler(top, participant, rec));

                participant.SetUdpTransportInfo(((UdpReceiver)rec).IP, ((UdpReceiver)rec).Port);

                return ReceiveDataHandlers[key];
            }
            return null;
        }
Пример #7
0
 public int GetSampleMaxSize()
 {
     return(topic.GetSampleMaxSize());
 }