Class Network

java.lang.Object
com.jme3.network.Network

public class Network extends Object
The main service provider for conveniently creating server and client instances.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Client
    connectToServer(String host, int hostPort)
    Creates a Client that communicates with the specified host and port using both reliable and fast transports.
    static Client
    connectToServer(String host, int hostPort, int remoteUdpPort)
    Creates a Client that communicates with the specified host and separate TCP and UDP ports using both reliable and fast transports.
    static Client
    connectToServer(String gameName, int version, String host, int hostPort)
    Creates a Client that communicates with the specified host and port using both reliable and fast transports.
    static Client
    connectToServer(String gameName, int version, String host, int hostPort, int remoteUdpPort)
    Creates a Client that communicates with the specified host and separate TCP and UDP ports using both reliable and fast transports.
    Creates a client that can be connected at a later time.
    createClient(String gameName, int version)
    Creates a client that can be connected at a later time.
    static Server
    createServer(int port)
    Creates a Server that will utilize both reliable and fast transports to communicate with clients.
    static Server
    createServer(int tcpPort, int udpPort)
    Creates a Server that will utilize both reliable and fast transports to communicate with clients.
    static Server
    createServer(String gameName, int version, int tcpPort, int udpPort)
    Creates a named and versioned Server that will utilize both reliable and fast transports to communicate with clients.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • createServer

      public static Server createServer(int port) throws IOException
      Creates a 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.
      Throws:
      IOException
    • createServer

      public static Server createServer(int tcpPort, int udpPort) throws IOException
      Creates a 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.
      Throws:
      IOException
    • createServer

      public static Server createServer(String gameName, int version, int tcpPort, int udpPort) throws IOException
      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.
      Parameters:
      gameName - This is the name that identifies the game. Connecting clients must use this name or be turned away.
      version - This is a game-specific version that helps detect when out-of-date clients have connected to an incompatible server.
      tcpPort - The port upon which the TCP hosting will listen for new connections.
      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.
      Throws:
      IOException
    • createClient

      public static NetworkClient createClient()
      Creates a client that can be connected at a later time.
    • createClient

      public static NetworkClient createClient(String gameName, int version)
      Creates a client that can be connected at a later time. The specified game name and version must match the server or the client will be turned away.
    • connectToServer

      public static Client connectToServer(String host, int hostPort) throws IOException
      Creates a Client that communicates with the specified host and port using both reliable and fast transports.
      Throws:
      IOException
    • connectToServer

      public static Client connectToServer(String host, int hostPort, int remoteUdpPort) throws IOException
      Creates a Client that communicates with the specified host and separate TCP and UDP ports using both reliable and fast transports.
      Throws:
      IOException
    • connectToServer

      public static Client connectToServer(String gameName, int version, String host, int hostPort) throws IOException
      Creates a Client that communicates with the specified host and port using both reliable and fast transports.
      Throws:
      IOException
    • connectToServer

      public static Client connectToServer(String gameName, int version, String host, int hostPort, int remoteUdpPort) throws IOException
      Creates a Client that communicates with the specified host and separate TCP and UDP ports using both reliable and fast transports.
      Parameters:
      gameName - This is the name that identifies the game. This must match the target server's name or this client will be turned away.
      version - This is a game-specific version that helps detect when out-of-date clients have connected to an incompatible server. This must match the server's version of this client will be turned away.
      hostPort - The remote TCP port on the server to which this client should send reliable messages.
      remoteUdpPort - The remote UDP port on the server to which this client should send 'fast'/unreliable messages. Set to -1 if 'fast' traffic should go over TCP. This will completely disable UDP traffic for this client.
      Throws:
      IOException