Exemplo n.º 1
0
 public static NetworkClient getInstance(string ipAddress, int sendPort, int listenPort)
 {
     if (instance == null)
     {
         instance = new NetworkClient(ipAddress, sendPort, listenPort);
         return instance;
     }
     instance.StopListening();
     instance.Set(ipAddress, sendPort, listenPort);
     return instance;
 }
Exemplo n.º 2
0
        private void ProcessKeyboardHome()
        {
            KeyboardState keybState = Keyboard.GetState();
            if (keybState.IsKeyDown(Keys.Enter))
            {
                Constant.LoadFromText(textboxAddress.Text);
                if(networkClient!=null)
                networkClient.StopListening();

                networkClient = NetworkClient.getInstance(Constant.SERVER_IP, Constant.SEND_PORT, Constant.LISTEN_PORT);

                //Join the game
                networkClient.Send("JOIN#");

                networkClient.StartListening();

                //To send messages
                msgSender = new Game.AI.MessageSender(networkClient);
                isHome = false;
            }
        }