public void Show(GlobalManager oldgm) { gm = oldgm; gm.flushPlayerList = new Action(FlushPlayerList); gm.warnPlayerFinishGame = new Action(WarnPlayerHaveFinishedGame); //set resources uiPlayerList.ItemsSource = gm.clientPlayerList; unitSelector = new List<SetUnitToggleButton>(); nowStep = 0; this.Show(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { gm = new GlobalManager(); gm.pingOut = new Action<string, Player>(pingOut); //set list uiPlayerList.ItemsSource = gm.clientPlayerList; //set back willBack = false; //set ip and port var selectPort = new Random().Next(6000, 40000); uiPort.Text = selectPort.ToString(); var localName = System.Net.Dns.GetHostName(); uiIP.Text = System.Net.Dns.GetHostByName(localName).AddressList.GetValue(0).ToString(); //开始监听 globalListener = new TcpListener(IPAddress.Any, selectPort); globalListener.Start(); globalListener.BeginAcceptTcpClient(new AsyncCallback(acceptCallback), globalListener); }