public final class NetcodeClientFactory
extends java.lang.Object
ChannelEventHandler and using an anonymous TLS cipher.
Every client provides an application id to the Netcode server. This
application id is used to ensure that only compatible clients join a single
channel. The server may also choose to accept only certain application ids.NetcodeClient| Constructor and Description |
|---|
NetcodeClientFactory(java.lang.String host,
int port,
java.lang.String appId)
Creates a new factory with the given host and port information and appId.
|
| Modifier and Type | Method and Description |
|---|---|
NetcodeClient |
createChannel(java.lang.String userId,
ChannelConfiguration configuration)
Creates a new Netcode channel.
|
NetcodeClient |
joinChannel(java.lang.String userId,
java.lang.String channelId)
Joins an existing Netcode channel.
|
void |
runAfterBind(java.util.function.Consumer<java.net.Socket> runner)
Adds a function to the post-bind queue.
|
void |
setMode(SocketMode socketMode,
SecurityMode securityMode)
Specifies both the socket mode and the security mode to use for new
connections.
|
public NetcodeClientFactory(java.lang.String host,
int port,
java.lang.String appId)
host - the server address. may not be null.port - the port number of the server. must be in the range 0-65535.appId - the application id to use for this client. may not be null.public void runAfterBind(java.util.function.Consumer<java.net.Socket> runner)
Socket or
SSLSocket as soon as it is created (but for SSLSockets before the
handshake). This allows arbitrary modification of the socket
configuration. This is especially useful for SSLSockets where more
control over the security configuration may be desired.
If the socket mode is set to SocketMode.PLAIN, the passed socket
will be of type Socket, for all other modes it will be a
SSLSocket.runner - the runner to add to the post-bind queue. may not be null.public void setMode(SocketMode socketMode, SecurityMode securityMode)
SocketMode.PLAIN, then the securityMode
must be set to SecurityMode.ANY.java.lang.IllegalArgumentException - an illegal combination has been providedjava.lang.NullPointerException - any parameter is nullpublic NetcodeClient createChannel(java.lang.String userId, ChannelConfiguration configuration) throws java.io.IOException, ConnectionException
userId - the userId for this client. may not be null.configuration - the channel configuration to use.java.io.IOException - an exception occured in the unterlying I/O elements.ConnectionException - a netcode connection could not be established. Usually this
indicates that some client data was rejected by the server.
See the exception type and message for more information.public NetcodeClient joinChannel(java.lang.String userId, java.lang.String channelId) throws java.io.IOException, ConnectionException
userId - the userId for this client. may not be null.channelId - the id of the channel to join. Channel IDs are generated by
the server upon channel generation.java.io.IOException - an exception occured in the unterlying I/O elements.ConnectionException - a netcode connection could not be established. Usually this
indicates that some client data was rejected by the server.
See the exception type and message for more information.Copyright © 2018. All Rights Reserved.