示例#1
0
        public string _username; //tên của showclient

        #endregion Fields

        #region Constructors

        public ShowClient(ClientManager cm,string username="",string IP_port="")
        {
            InitializeComponent();
            lbl_username.Text = username;
            _username = username;
            lbl_ip_port.Text = IP_port;
            _cm = cm;
        }
示例#2
0
        public string _username; //tên của showclient

        #endregion Fields

        #region Constructors

        public ShowClient(ClientManager ClientTemp,string username="",string IP_address="",int Port=0)
        {
            InitializeComponent();
            lbl_username.Text = username;
            _username = username;
            lbl_ip_port.Text = IP_address;
            client = ClientTemp;
            Online = false;
        }
示例#3
0
 public Chat(ClientManager cm)
 {
     InitializeComponent();
     _cm = cm;
     text = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular);
 }
示例#4
0
        public void bw_DoWork(object sender,DoWorkEventArgs e)
        {
            server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            server.Bind(ipep);

            server.Listen(10);
            // 1. listen
            while (true)
            {
                semaphor.WaitOne();
                Socket _socket = server.Accept();//chờ đợi client kết nối đến
                client = new ClientManager(this, _socket);//tạo client giữa server với client vừa kết nối để giữ liên lạc
                // 2. Nhận thông tin tài khoản được gởi đến từ bên client
                semaphor.Release();
            }
              //kết thúc lắng nghe
        }
示例#5
0
 public void Offline(ClientManager user)
 {
     for (int i = 0; i < Form1.lstShowClient.Count; i++)
     {
         if (Form1.lstShowClient[i]._username == user.userName)
         {
             //tìm user vừa thoát và làm đỏ ShowClient .
             if (Form1.lstShowClient[i].client != null && Form1.lstShowClient[i].Online == true
                 && Form1.lstShowClient[i].client.ipAdress == user.ipAdress && Form1.lstShowClient[i].client.Port == user.Port)
             {
                 //gán cho CLientManger trong show client là null
                 Form1.lstShowClient[i].BackColor = System.Drawing.Color.Firebrick;
                 Form1.lstShowClient[i].client = null;
                 Form1.lstShowClient[i].Online = false;
             }
         }
     }
     for (int i = 0; i < Form1.listClient.Count; i++)
     {
         //tìm user vừa thoát kết nối và remove khỏi list client
         if (Form1.listClient[i].userName == user.userName)
             Form1.listClient.Remove(Form1.listClient[i]);
     }
 }