hi,I have two new problems now
can someone give advices to me? Thanks
the first problem is that when I call the ClientMain from the GameMain program(I use ClientM.main(xxx) inside the GameMain to call the ClientMain, is that right?), if the ClientMain is using app.start(JmeContext.Type.Display), the program will be down. When I change app.start(JmeContext.Type.Display) to app.start(), the problem is still there. When I change app.start(JmeContext.Type.Display) to app.start(JmeContext.Type.Headless), the program becomes normal, but I know this is not the proper way to do it…
So how can I run the ClientMain normally?
the second problem is that when I test the clientMain(which is using JmeContext.Type.Headless for start()), if I put “127.1.1.1” or “localhost” to be the host, the connection is successful. But if I put my external ip address(for example: 123.203.200.200), the connection is failed.Does anyone know what is the problem? How can I use that ip address to test my game?
here is the ClientMain I use:
[java]
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.network.Client;
import com.jme3.network.Message;
import com.jme3.network.Network;
import com.jme3.network.serializing.Serializer;
import com.jme3.system.JmeContext;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ClientM extends SimpleApplication {
private Client client;
static ClientM app;
public static void main(String args[]) {
app = new ClientM();
app.start(JmeContext.Type.Display);
}
@Override
public void simpleInitApp() {
try {
client = Network.connectToServer("My Cool Game", 1, "localhost", 6143);
client.start();
} catch (IOException ex) {
Logger.getLogger(ServerM.class.getName()).log(Level.SEVERE, null, ex);
}
Serializer.registerClass(GreetingMessage.class);
client.addMessageListener(new ClientListener(),
GreetingMessage.class);
Message m = new GreetingMessage("Hi server, do you hear me?");
client.send(m);
}
@Override
public void update() {
}
@Override
public void destroy() {
client.close();
super.destroy();
}
}
[/java]