Please dont lynch me after reading my question.
Right now im reading the networking tutorial. There is a paragraph which states that it is possible to set the game name.
Here is what i did:
[java]
import com.jme3.app.SimpleApplication;
import com.jme3.network.Network;
import com.jme3.network.Server;
import com.jme3.network.serializing.Serializer;
import com.jme3.system.JmeContext;
public class ServerMain extends SimpleApplication {
Server myServer;
@Override
public void simpleInitApp() {
try {
myServer = Network.createServer(6143);
myServer.start();
Serializer.registerClass(MyGameMessage.class);
myServer.addMessageListener(new MyServerMessageListener(), MyGameMessage.class);
} catch (Exception ex) {
System.out.println(“Exception occured”);
}
}
@Override
public void simpleUpdate(float tpf) {
MyGameMessage message = new MyGameMessage(“hel”,“lo”);
myServer.broadcast(message);
}
public static void main(String[] args) {
ServerMain app = new ServerMain();
app.start(JmeContext.Type.Headless);
}
}
[/java]
I mean everything works fine, but i can’t do a “myServer.setName(“my game name”)” anywhere, because the method is not found!
What to do here ?
Actually it appears the documentation is out of date. No lynching needed
This createServer() method on Network is what you want to call to pass in a game name:
[java]
/**
- Creates a named and versioned Server that will utilize both reliable and fast
- transports to communicate with clients. The specified port
- will be used for both TCP and UDP communication.
*
-
@param gameName This is the name that identifies the game. Connecting clients
-
must use this name or be turned away.<br />
-
@param version This is a game-specific verison that helps detect when out-of-date
-
clients have connected to an incompatible server.<br />
-
@param tcpPort The port upon which the TCP hosting will listen for new connections.
-
@param udpPort The port upon which the UDP hosting will listen for new ‘fast’ UDP
-
messages. Set to -1 if 'fast' traffic should go over TCP. This will<br />
-
completely disable UDP traffic for this server.<br />
*/
public static Server createServer( String gameName, int version, int tcpPort, int udpPort )
[/java]
I will update the documentation to reflect the changes.
You’ve never been able to set the game name except during creation. So I’m not sure where that comes from exactly.
Sploreg is right about the solution. Sometimes it helps to read the javadocs for a class to see what kinds of things it does. It’s the most accurate documentation since it generally gets changed with the code.
Nobody lynchs new people over here, what happens is that they normally skip the tutorials (which you didn’t!), and that’s where normally 95% of the questions comes from. And even in those cases, normally most people just ask them to read the tutorails ^^
ok i understand the static Network-class has another overloaded static method for creating a game.