Hello monkeys around! This question is more realted to @pspeed.
So, I always tested my server on the same computer. Now, I want to test it outside. I tried use hamachi and opening ports, but I can’t connect to my server. I noted that in the server, there is no host field to fill. Is that the problem or is another thing?
Server code:
private void initServer() throws IOException {
server = Network.createServer("Cidade", 1, 6114, 6114);
server.start();
server.addMessageListener(this, JogadorEntrou.class, JogadorPos.class);
server.addConnectionListener(this);
System.out.println("Server on!");
}
Client code (I used the Hamachi ip in this code to hide my public ip):
private void initClient() {
try {
client = Network.connectToServer("Cidade", 1, "25.150.242.43", 6114);
client.start();
client.addMessageListener(this, JogadorEntrou.class, JogadorSaiu.class, JogadorPos.class);
} catch(ConnectException ce) {
JOptionPane.showMessageDialog(null, "O servidor ainda não está ligado! Carrega em OK e abre outra vez o jogo!");
ce.printStackTrace();
System.exit(-1);
} catch(IOException ioe) {
JOptionPane.showMessageDialog(null, "Não foi possível entrar no servidor! Avisa o Ricardo!");
ioe.printStackTrace();
System.exit(-1);
}
}
Thanks,
Ev1lbl0w