예제 #1
0
 public void Stop()
 {
     lock (mutex) {
         if (socket != null) {
             socket.Close ();
             socket = null;
         }
     }
 }
예제 #2
0
        public void Start()
        {
            lock (mutex) {
                Stop ();

                socket = new SsdpSocket ();
                socket.Bind ();
                AsyncReadResult (socket);
            }
        }
예제 #3
0
        public void Start()
        {
            lock (mutex) {
                Stop();

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

                socket = new MulticastSsdpSocket(server.NetworkInterfaceInfo);
                socket.Bind();
                AsyncReadResult(socket);
            }
        }
예제 #6
0
 public void Start ()
 {
     lock (mutex) {
         Stop ();
         
         socket = new MulticastSsdpSocket (client.NetworkInterfaceInfo);
         socket.Bind ();
         AsyncReadResult (socket);
     }
 }
예제 #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;
            }
        }
예제 #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;
 }
예제 #10
0
 internal void AsyncReadResult(SsdpSocket socket)
 {
     AsyncReadResult(new AsyncReceiveBuffer (socket));
 }
예제 #11
0
 public AsyncReceiveBuffer(SsdpSocket socket)
 {
     this.socket = socket;
 }
예제 #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);
                }
            }
        }
예제 #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;
                }
            }
        }