public void FigureMovedHandler(BaseNetwork.MoveFigureEventArgs args) { playWindow.Invoke(new MethodInvoker(delegate { MoveFigure(args.OldPos, args.NewPos); strokeLock = false; })); Console.WriteLine("Figure moved handler called"); Debug.NewMessage("Figure moved called by " + Thread.CurrentThread.Name); }
private void StartServer() { playWindow.NetworkEnabled = true; strokeLock = true; endGameLock = false; playWindow.Text = "Chess - Server"; networkGame = true; playWindow.Show(); try { network = new NetworkServer(); RegisterNetEventHandlers(); ((NetworkServer)network).StartServer(); } catch (Exception e) { MessageBox.Show(e.Message, "Server Error"); Debug.NewMessage(this.ToString() + e.Message); } Debug.NewMessage(this.ToString() + " serve initalizated..."); }
private void EndGame() { endGameLock = true; if (network != null) { network.Disconnect(); network = null; } }
private void StartClient(string ip) { playWindow.NetworkEnabled = true; strokeLock = false; endGameLock = false; networkGame = true; playWindow.Text = "Chess - Client"; playWindow.Show(); Debug.NewMessage(this.ToString() + " connecting to server " + ip); try { strokeLock = true; network = new NetworkClient(); RegisterNetEventHandlers(); ((NetworkClient)network).ConnetcToServer(ip); } catch (Exception e) { MessageBox.Show(e.Message, "Error"); Debug.NewMessage(this.ToString() + " " + e.Message); } }
public void MessageReceivedHandler(BaseNetwork.MessageReceivedEventArgs args) { playWindow.Invoke(new MethodInvoker(delegate { playWindow.PrintMessage(args.Message, (network.type == NetWorkType.SERVER) ? (PlayWindow.MessageOwner.Player1) : (PlayWindow.MessageOwner.Player2)); })); Debug.NewMessage("Message received: " + args.Message); }