Ejemplo n.º 1
0
 /// <summary>
 /// Constructor van de client. Deze verbind met de server en start de communicatie in een apart thread.
 /// </summary>
 /// <param name="target">Ip adres van de server</param>
 /// <param name="port">Poort van de server</param>
 public Client(IPAddress target, int port)
 {
     if (client == null)
     {
         client = this;
         _ip = target;
         _port = port;
     }
 }
Ejemplo n.º 2
0
        public void ConnectTo(System.Net.IPAddress ip, int port)
        {
            DisposeCommunication();
            Client client = new Client(ip, port);
            _communication = client;
            KaroGameManager = new KaroCommunicatedGameManager(_communication);

            // Attach handlers
            KaroGameManager.OnPlayerWin += PlayerWon;
            client.OnConnectionFailed += ConnectionFailed;
            AddGlobalHandlers();

            _communication.StartCommunicating();
            AddGameComponents();
        }
Ejemplo n.º 3
0
 private void clientToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try {
         InputBox i = new InputBox();
         i.ShowDialog();
         string[] split = i.ResultText.Split(':');
         Client communication = new Client(IPAddress.Parse(split[0]), Int32.Parse(split[1]));
         _manager = new KaroCommunicatedGameManager(communication);
         communication.OnConnectionFailed += CommunicationFailed;
         communication.StartCommunicating();
         _communication = communication;
         karoPanel.NewGame(_manager);
     } catch(Exception) {
         MessageBox.Show("IP incorrect");
     }
 }