コード例 #1
0
ファイル: Server.cs プロジェクト: rexey3s/Arena100Gameshow
        /// <summary>
        /// tạo kết nối mới cho client dc chấp nhận 
        /// </summary>
        /// <param name="clientSock"></param>
        /// <param name="id"></param>
        private void NewConnection(Socket clientSock, PlayerID id)
        {
            pClient client = new pClient(clientSock, id);

            _PlayerList.Add(client);
            ListViewItem item = new ListViewItem();
            ListViewItem.ListViewSubItemCollection subitems = new ListViewItem.ListViewSubItemCollection(item);
            item.Tag = client;

            GUI.EditListView(item, subitems);

            byte[] Helo = _ENCODE.GetBytes("HELO\n" + GUI.timeOutSecond.ToString() + "\n" + GUI._ContainerList.Capacity.ToString() + "\n" + "Connected at: " + DateTime.Now.ToLongTimeString());
            client.sock.Send(Helo);
            client.SetupForRecv(this);
        }
コード例 #2
0
ファイル: Mainform.cs プロジェクト: baochuong1901/nt106
        private void NewConnection(Socket clientSock)
        {
            pClient client = new pClient(clientSock);
            clientList.Add(client);
            ListViewItem item = new ListViewItem();
            ListViewItem.ListViewSubItemCollection subitems = new ListViewItem.ListViewSubItemCollection(item);
            item.Tag = client;

            EditListView(item,subitems);

            byte[] HelloMess = ENCODE.GetBytes("Welcome " + DateTime.Now.ToLongTimeString());
            client.socket.Send(HelloMess, HelloMess.Length, 0);
            client.SetupForRecv(this);
        }
コード例 #3
0
ファイル: Mainform.cs プロジェクト: rexey3s/Arena100Gameshow
 /// <summary>
 /// Xóa các item chứa các client ko còn kết nối vs server
 /// </summary>
 /// <param name="tag"></param>
 public void RemoveListViewItem(pClient tag)
 {
     if (listView1.InvokeRequired)
     {
         RemoveItemListViewCallback d = new RemoveItemListViewCallback(RemoveListViewItem);
         listView1.Invoke(d, new object[] { tag });
     }
     else
     {
         foreach (ListViewItem item in listView1.Items)
         {
             if (item.Tag.Equals(tag))
                 listView1.Items.Remove(item);
         }
     }
 }