Esempio n. 1
0
        public bool GetCurrentChannelConfiguration(EndPointConfiguration endpA, EndPointConfiguration endpB)
        {
            try
            {
                IPAddress addrA = (netAddressesA.SelectedItem as IPAddressItem).IpAddress.Address;

                int portA = int.Parse(channAPort.Text);


                IPAddress addrB = (netAddressesB.SelectedItem as IPAddressItem).IpAddress.Address;

                int portB = int.Parse(channBPort.Text);


                if (endpA != null && endpB != null)
                {
                    endpA.ListeningAddress = addrA;
                    endpA.ListeningPort    = portA;

                    endpB.ListeningAddress = addrB;
                    endpB.ListeningPort    = portB;

                    return(true);
                }
            }
            catch
            {
                return(false);
            }


            return(false);
        }
Esempio n. 2
0
        private void startChannelButton_Click(object sender, RoutedEventArgs e)
        {
            //verifico che il canale sia ben configurato
            if (CheckChannelConfiguration())
            {
                //canali disponibili
                mChannelA = new EndPointTranceiver(this);
                mChannelB = new EndPointTranceiver(this);

                EndPointConfiguration cA = new EndPointConfiguration();
                EndPointConfiguration cB = new EndPointConfiguration();

                if (GetCurrentChannelConfiguration(cA, cB))
                {
                    ConcurrentQueue <QueuePacket> iAtoBq = new ConcurrentQueue <QueuePacket>();
                    ConcurrentQueue <QueuePacket> iBtoAq = new ConcurrentQueue <QueuePacket>();

                    cA.InputQueue = iAtoBq;
                    cB.InputQueue = iBtoAq;

                    cA.OutputQueue = iBtoAq;
                    cB.OutputQueue = iAtoBq;


                    mChannelA.Configuration = cA;
                    mChannelB.Configuration = cB;
                }
                else
                {
                    return;
                }

                mChannelA.StartEndPoint();
                mChannelB.StartEndPoint();
            }
            else
            {
                MessageBox.Show("Errore nell'apertura dei due endpoint");
                return;
            }
        }