public void Stop()
 {
     lock (mutex) {
         if (socket != null) {
             socket.Close ();
             socket = null;
         }
     }
 }
        public void Start()
        {
            lock (mutex) {
                Stop ();

                socket = new SsdpSocket ();
                socket.Bind ();
                AsyncReadResult (socket);
            }
        }
        public void Start()
        {
            lock (mutex) {
                Stop();

                socket = new SsdpSocket();
                socket.Bind();
                AsyncReadResult(socket);
            }
        }
 public void Stop()
 {
     lock (mutex) {
         if (socket != null)
         {
             socket.Close();
             socket = null;
         }
     }
 }
Exemple #5
0
        public void Start()
        {
            lock (mutex) {
                Stop();

                socket = new MulticastSsdpSocket(server.NetworkInterfaceInfo);
                socket.Bind();
                AsyncReadResult(socket);
            }
        }
 public void Start ()
 {
     lock (mutex) {
         Stop ();
         
         socket = new MulticastSsdpSocket (client.NetworkInterfaceInfo);
         socket.Bind ();
         AsyncReadResult (socket);
     }
 }
Exemple #7
0
        public void Stop()
        {
            lock (mutex) {
                CheckDisposed ();

                if (!started) {
                    return;
                }

                WaitHandle[] handles = new WaitHandle[announcers.Count];
                int i = 0;
                foreach (Announcer announcer in announcers.Values) {
                    handles[i++] = announcer.StopAsync ();
                }

                request_listener.Stop ();
                respondSocket.Close ();
                respondSocket = null;
                WaitHandle.WaitAll (handles);
                announceSocket.Close ();
                announceSocket = null;
                started = false;
            }
        }
Exemple #8
0
        public void Start(bool startAnnouncers)
        {
            lock (mutex) {
                CheckDisposed ();

                if (started) {
                    throw new InvalidOperationException ("The Server is already started.");
                }

                started = true;
                request_listener.Start ();
                announceSocket = new SsdpSocket ();
                announceSocket.Bind (new IPEndPoint (IPAddress.Any, 0));
                respondSocket = new SsdpSocket (false);
                respondSocket.Bind (new IPEndPoint (IPAddress.Any, Protocol.Port));

                if (startAnnouncers) {
                    foreach (Announcer announcer in announcers.Values) {
                        if (!announcer.Started) {
                            announcer.Start ();
                        }
                    }
                }
            }
        }
 public AsyncReceiveBuffer(SsdpSocket socket)
 {
     this.socket = socket;
 }
 internal void AsyncReadResult(SsdpSocket socket)
 {
     AsyncReadResult(new AsyncReceiveBuffer (socket));
 }
Exemple #11
0
 public AsyncReceiveBuffer(SsdpSocket socket)
 {
     this.socket = socket;
 }
Exemple #12
0
        public void Start ()
        {
            lock (mutex) {
                CheckDisposed ();

                if (Started) {
                    throw new InvalidOperationException ("A browse operation is already running. Cancel it first.");
                } else if (String.IsNullOrEmpty (service_type)) {
                    throw new ArgumentNullException ("ServiceType");
                }
                
                socket = new MulticastSsdpSocket (client.NetworkInterfaceInfo);
                socket.BeginSendTo (Protocol.CreateDiscoveryRequest (service_type, MX), OnBrowseRequestFinished);

                // wait for 4 times MX
                if (AutoStop) {
                    timout_id = client.Dispatcher.Add (TimeSpan.FromSeconds (MX * 3), OnTimeout);
                }
                
                if (!client.Started) {
                    client.Start (false);
                }
            }
        }
Exemple #13
0
        public void Stop ()
        {
            lock (mutex) {
                CheckDisposed ();

                if (timout_id != 0) {
                    client.Dispatcher.Remove (timout_id);
                    timout_id = 0;
                }
                
                if (socket != null) {
                    socket.Close ();
                    socket = null;
                }
            }
        }