Esempio n. 1
0
        ///LA TODO Protection ?? What if several subscribers at the same time
        /// Not needed since all calls go through the participant which is synched
        public ISendDataHandler GetSendDataHandler(Topic t, Participant participant)
        {
            // Get the local interface, doing a translation from subnet if necessary
            string localIF = InetAddress.DoSubnetTranslation(t.GetLocalInterface());
            string key     = MakeKey(t, localIF);

            if (SendDataHandlers.ContainsKey(key))
            {
                ISendDataHandler sender = SendDataHandlers[key];
                if (t.GetTransport().Equals(Topic.TRANSPORT_UDP))
                {
                    PostSetup(t, participant, (McUdpSendDataHandler)sender);
                }
                return(sender);
            }

            try
            {
                ISendDataHandler sender = null;
                if (t.GetTransport().Equals(Topic.TRANSPORT_MC))
                {
                    sender = new McSendDataHandler(t, localIF, t.GetTimeToLive());
                }
                else if (t.GetTransport().Equals(Topic.TRANSPORT_TCP))
                {
                    sender = new TcpSendDataHandler(t, localIF);
                }
                else if (t.GetTransport().Equals(Topic.TRANSPORT_UDP))
                {
                    // We have only one sender for all topics on an interface, so use the domain value for buffer size
                    sender = new McUdpSendDataHandler(participant.getDomain().GetOutSocketBufferSize(), localIF);
                    PostSetup(t, participant, (McUdpSendDataHandler)sender);
                }
                if (sender != null)
                {
                    SendDataHandlers.Add(key, sender);
                    return(sender);
                }

                throw new CommException("No such Transport " + t.GetTransport());
            }
            catch (System.IO.IOException ex)
            {
                throw new CommException("Error creating SendDataHandler. IOException -->" + ex.Message);
            }
        }
Esempio n. 2
0
 void checkTopicValues(Topic top)
 {
     if (top.GetDomainAddress().Equals(""))
     {
         top.SetDomainAddress(domainAddress);
     }
     if (top.GetLocalInterface().Equals(""))
     {
         top.SetLocalInterface(localInterface);
     }
     if (top.GetTimeToLive() < 0)
     {
         top.SetTimeToLive(timeToLive);
     }
     if (top.GetInSocketBufferSize() < 0)
     {
         top.SetInSocketBufferSize(inSocketBufferSize);
     }
     if (top.GetOutSocketBufferSize() < 0)
     {
         top.SetOutSocketBufferSize(outSocketBufferSize);
     }
     top.SetOptNonVirt(optNonVirt);
 }