Search in sources :

Example 1 with UdpKernel

use of com.jme3.network.kernel.udp.UdpKernel in project jmonkeyengine by jMonkeyEngine.

the class Network method createServer.

/**
     *  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.
     *  @param version  This is a game-specific verison that helps detect when out-of-date
     *                  clients have connected to an incompatible server.
     *  @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
     *                  completely disable UDP traffic for this server.
     */
public static Server createServer(String gameName, int version, int tcpPort, int udpPort) throws IOException {
    UdpKernel fast = udpPort == -1 ? null : new UdpKernel(udpPort);
    SelectorKernel reliable = new SelectorKernel(tcpPort);
    return new DefaultServer(gameName, version, reliable, fast);
}
Also used : DefaultServer(com.jme3.network.base.DefaultServer) SelectorKernel(com.jme3.network.kernel.tcp.SelectorKernel) UdpKernel(com.jme3.network.kernel.udp.UdpKernel)

Aggregations

DefaultServer (com.jme3.network.base.DefaultServer)1 SelectorKernel (com.jme3.network.kernel.tcp.SelectorKernel)1 UdpKernel (com.jme3.network.kernel.udp.UdpKernel)1