Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="service"></param>
        /// <param name="fs"></param>
        /// <returns></returns>
        private static String showService(NetService service, Boolean fs) {
            IList addresses = service.Addresses;
            String streamId = DisplayCastGlobals.PLAYER_CMD_SYNTAX_ERROR;

            if (scrnNum < 0) {
                if (allScreen.Length > 1)
                    scrnNum = 1;
                else
                    scrnNum = 0;
            }

            Trace.WriteLine("DEBUG: Trying to connect to " + service.Name);
            foreach (System.Net.IPEndPoint addr in addresses) {
                System.Net.Sockets.TcpClient clntSocket = new System.Net.Sockets.TcpClient();
                try {
                    clntSocket.Connect(addr);
                    if (clntSocket.Connected) {
                        Trace.WriteLine("DEBUG: Connected to " + service.Name);

                        Streamer s = new Streamer(service.Name, getName(service), clntSocket.GetStream(), fs, nsPublisher, TXTrecords, allScreen[scrnNum++].Bounds);
                        if (scrnNum == allScreen.Length)
                            scrnNum = 0;

                        s.Show();
                        streamId = s.GetHashCode().ToString();
                        streamers.Add(s);

                        break;
                    }
                } catch {
                }
            }

            return streamId;
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="service"></param>
        /// <param name="moreComing"></param>
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            ArrayList itemsToRemove = new ArrayList();

#if PLAYER_TASKBAR
            foreach (MenuItem item in streamersItem.MenuItems)
            {
                if (item.Tag == service)
                {
                    itemsToRemove.Add(item);
                }
            }

            foreach (MenuItem item in itemsToRemove)
            {
                streamersItem.MenuItems.Remove(item);

                while (true)
                {
                    Streamer toDelete = null;

                    foreach (Streamer strm in streamers)
                    {
                        if (strm.id.Equals(service.Name))
                        {
                            strm.Close();
                            toDelete = strm;
                            break;
                        }
                    }

                    if (toDelete != null)
                    {
                        streamers.Remove(toDelete);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            itemsToRemove.Clear();
#else
            browserList.BeginUpdate();

            foreach (ListViewItem item in browserList.Items)
            {
                if (item.Tag == service)
                {
                    itemsToRemove.Add(item);
                }
            }

            foreach (ListViewItem item in itemsToRemove)
            {
                browserList.Items.Remove(item);

                while (true)
                {
                    Streamer toDelete = null;

                    foreach (Streamer strm in streamers)
                    {
                        if (strm.id.Equals(service.Name))
                        {
                            strm.Close();
                            toDelete = strm;
                            break;
                        }
                    }

                    if (toDelete != null)
                    {
                        streamers.Remove(toDelete);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            itemsToRemove.Clear();
            browserList.EndUpdate();
#endif
            service.Dispose();
        }