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; }
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; } }