コード例 #1
0
ファイル: Program.cs プロジェクト: psyCHOder/conferencexp
        public TestProgram(bool useMulticast)
        {
            IPEndPoint multicastEP = new IPEndPoint(IPAddress.Parse(multicastAddr), multicastPort);
            IPEndPoint reflectorEP = new IPEndPoint(IPAddress.Parse(reflectorAddr), reflectorPort);

            if (useMulticast)
            {
                listener = new UdpListener(multicastEP, 0);
                sender = new UdpSender(multicastEP, 64);
            }
            else
            {
                // reflector
                //listener = new UdpListener(multicastEP, reflectorEP, 0);
                sender = new UdpSender(reflectorEP, 64);
            }

            Thread thread1 = new Thread(SendSomeStuff);
            thread1.Start();

            Thread thread2 = new Thread(ReceiveSomeStuff);
            thread2.Start();
        }
コード例 #2
0
        public HeartbeatMonitor()
        {
            // XXX make this config parameters
            IPAddress addr = IPAddress.Parse("233.0.73.19");
            IPEndPoint ep = new IPEndPoint(addr,DEFAULT_PORT);

            try {
                multicastListener = new UdpListener(ep, TIMEOUT);
            }
            catch (SocketException) { 
                //Exception here probably means there is no network.  
                //In this case we just leave the heartbeat monitor off.
                return;
            }

            reflectorSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            reflectorSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout,TIMEOUT);   

            this.WorkerSupportsCancellation = false;
            this.WorkerReportsProgress = true;
            this.DoWork += new DoWorkEventHandler(HeartbeatMonitor_DoWork);

            this.RunWorkerAsync();
        }
コード例 #3
0
ファイル: VenueBroker.cs プロジェクト: abhishek-kumar/AIGA
        /// <summary>
        /// Creates a venue with IPAddress 234.*.*.* where each * is randomly generated.  Extremely useful
        /// in the case where a venue server is inaccessible.
        /// </summary>
        public Venue CreateRandomMulticastVenue( string name, Image icon )
        {
            IPEndPoint endPoint = null;
            bool trafficInVenue = true;
            while (trafficInVenue)
            {
                #region Randomly choose the Venue's IP address
                Random rnd = new Random();
                int randomaddr = 234;
                randomaddr = randomaddr * 256 + rnd.Next(1, 2^8 - 1);
                randomaddr = randomaddr * 256 + rnd.Next(1, 2^8 - 1);
                randomaddr = randomaddr * 256 + rnd.Next(1, 2^8 - 1);
                endPoint = new IPEndPoint(IPAddress.HostToNetworkOrder(randomaddr), 5004);
                #endregion
                #region Detect whether there is already traffic in the venue, if so change the IP address
                BufferChunk bc = new BufferChunk(MSR.LST.Net.Rtp.Rtp.MAX_PACKET_SIZE);
                UdpListener udpListener = new UdpListener(endPoint, venueInUseTimeout);
                try
                {
                    udpListener.Receive(bc);
                }
                catch (System.Net.Sockets.SocketException e)
                {
                    if (e.ErrorCode == 10060)
                    {
                        trafficInVenue = false;
                    }
                    else
                    {
                        throw;
                    }
                }
                finally
                {
                    udpListener.Dispose();
                }
                #endregion
            }

            VenueData venueData = new VenueData( name, endPoint, 5, VenueType.Custom, icon );

            return AddCustomVenue(venueData);
        }
コード例 #4
0
ファイル: Global.asax.cs プロジェクト: psyCHOder/conferencexp
        //private SenderData getSenderData(VenueState venueState, uint ssrc)
        //{
        //    lock (venueState.SenderData)
        //    {
        //        if (venueState.SenderData.ContainsKey(ssrc))
        //            return venueState.SenderData[ssrc];
        //        else return new SenderData();
        //    }
        //}




        protected void Application_End(object sender, EventArgs e)
        {
            isRunning = false;
            writeEventLog("Diagnostic Service ending.", EventLogEntryType.Information);

            if (udpListener != null)
            {
                udpListener.Dispose();
                udpListener = null;
            }
        }
コード例 #5
0
ファイル: Global.asax.cs プロジェクト: psyCHOder/conferencexp
        protected void Application_Start(object sender, EventArgs e)
        {
            try {
                if (EventLog.SourceExists(EVENT_LOG_SOURCE)) {
                    eventLog = new EventLog("Application");
                    eventLog.Source = EVENT_LOG_SOURCE;
                    eventLog.WriteEntry("Diagnostic Service starting.");
                }
            }
            catch {
                eventLog = null;
            }

            int diagPort;
            if (int.TryParse(ConfigurationManager.AppSettings["DiagnosticPort"], out diagPort)) {
                if (diagPort > 0) DIAGNOSTIC_PORT = diagPort;
            }

            bool loggingEnable;
            if (bool.TryParse(ConfigurationManager.AppSettings["LoggingEnabled"], out loggingEnable)) {
                LoggingEnabled = loggingEnable;
            }
    
           // Start a UDP socket to receive RTCP traffic
            IPAddress localAll = IPAddress.Any;
            //IPAddress multicastAdr = IPAddress.Parse(addr);
               
            IPEndPoint endPoint = new IPEndPoint(localAll,DIAGNOSTIC_PORT);

            udpListener = new UdpListener(endPoint, 0);
            isRunning = true;

            Thread thread = new Thread(Start);
            thread.IsBackground = true;
            thread.Name = "UDP receive thread";
            thread.Start();

            theInstance = this;
        }