示例#1
0
        /// <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
        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
 /// <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);
         }
     }
 }