private void MainForm_Load(object sender, EventArgs e) { SocketPacket reqfriendpacket = new SocketPacket(PacketType.REQFRIEND, getlocalIP(), serverip, 52052, 52054); DataTranferer.Send(serverip, 52054, reqfriendpacket); ThreadStart receivethread = new ThreadStart(ReceiveFromServer); Thread thread1 = new Thread(receivethread); thread1.IsBackground = true; thread1.Start(); }
private void button1_MouseClick(object sender, MouseEventArgs e) { this.Visible = false; SocketPacket packet = new SocketPacket(PacketType.REQCON, localIP, txbserverip.Text, 52052, 52054, txbName.Text); SocketPacket returnpacket = DataTranferer.SendAndReceive(txbserverip.Text, 52054, packet); if (returnpacket.Message == "OK") { MainForm main = new MainForm(txbserverip.Text, txbName.Text); main.ShowDialog(); this.Close(); } else { MessageBox.Show(returnpacket.Message); } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { SocketPacket disconnect = new SocketPacket(PacketType.DISCON, getlocalIP(), serverip, 52052, 52054); DataTranferer.Send(serverip, 52052, disconnect); }