/// <summary> /// 开始监听指定用户的信息 /// </summary> public void reciveMessageBegin(User user) { MessageReciver reciver = new MessageReciver(user); user.Thread = new Thread(reciver.begin); user.Thread.Start(); }
public Petrum(bool Host, int Port, string IP = null) { InitializeComponent(); Path = System.Environment.CurrentDirectory; chargementOK = true; try { bpLapin = (Bitmap)Bitmap.FromFile(Path + "/Lapin.bmp"); bpHerbe = (Bitmap)Bitmap.FromFile(Path + "/Herbe.bmp"); bpLoup = (Bitmap)Bitmap.FromFile(Path + "/Loup.bmp"); } catch (Exception e) { MessageBox.Show("Textures Introuvables " + e.Message); chargementOK = false; } this.Resize += Petrum_Resize; this.KeyDown += MainWindow_KeyDown; MessageReciver.DoWork += MessageReciver_DoWork; CheckForIllegalCrossThreadCalls = false; Plat = new Plateau(herbeInit); Maj(); if (Host) { Joueur = 0; Serveur = new TcpListener(System.Net.IPAddress.Any, Port); Serveur.Start(); UnfreezePlateau(); Sock = Serveur.AcceptSocket(); } else { Joueur = 1; try { Client = new TcpClient(IP, Port); Sock = Client.Client; MessageReciver.RunWorkerAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message); Close(); } } }