Package com.jme3.network.base
Class DefaultClient
java.lang.Object
com.jme3.network.base.DefaultClient
- All Implemented Interfaces:
Client,MessageConnection
- Direct Known Subclasses:
Network.NetworkClientImpl
A default implementation of the Client interface that delegates
its network connectivity to a kernel.Connector.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface com.jme3.network.MessageConnection
CHANNEL_DEFAULT_RELIABLE, CHANNEL_DEFAULT_UNRELIABLE -
Constructor Summary
ConstructorsConstructorDescriptionDefaultClient(String gameName, int version) DefaultClient(String gameName, int version, Connector reliable, Connector fast, ConnectorFactory connectorFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClientStateListener(ClientStateListener listener) Adds a listener that will be notified about connection state changes.voidaddErrorListener(ErrorListener<? super Client> listener) Adds a listener that will be notified when any connection errors occur.voidaddMessageListener(MessageListener<? super Client> listener) Adds a listener that will be notified when any message or object is received from the server.voidaddMessageListener(MessageListener<? super Client> listener, Class... classes) Adds a listener that will be notified when messages of the specified types are received.protected voidprotected voidvoidclose()Closes this connection to the server.protected voidprotected voidconfigureChannels(long tempId, int[] ports) protected voidprotected voidprotected voidReturns the 'game name' for servers to which this client should be able to connect.intgetId()Returns a unique ID for this client within the remote server or -1 if this client isn't fully connected to the server.Returns the manager for client services.intReturns the game-specific version of the server this client should be able to connect to.protected voidEither calls the ErrorListener or closes the connection if there are no listeners.booleanReturns true if this client is fully connected to the host.booleanReturns true if this client has been started and is still running.voidremoveClientStateListener(ClientStateListener listener) Removes a previously registered connection listener.voidremoveErrorListener(ErrorListener<? super Client> listener) Removes a previously registered error listener.voidremoveMessageListener(MessageListener<? super Client> listener) Removes a previously registered wildcard listener.voidremoveMessageListener(MessageListener<? super Client> listener, Class... classes) Removes a previously registered type-specific listener from the specified types.voidSends a message to the other end of the connection using the specified alternate channel.protected voidvoidSends a message to the server.protected voidsetPrimaryConnectors(Connector reliable, Connector fast, ConnectorFactory connectorFactory) voidstart()Starts the client allowing it to begin processing incoming messages and delivering them to listeners.protected voidprotected void
-
Constructor Details
-
DefaultClient
-
DefaultClient
public DefaultClient(String gameName, int version, Connector reliable, Connector fast, ConnectorFactory connectorFactory)
-
-
Method Details
-
addStandardServices
protected void addStandardServices() -
setPrimaryConnectors
protected void setPrimaryConnectors(Connector reliable, Connector fast, ConnectorFactory connectorFactory) -
checkRunning
protected void checkRunning() -
start
public void start()Description copied from interface:ClientStarts the client allowing it to begin processing incoming messages and delivering them to listeners. -
isStarted
public boolean isStarted()Description copied from interface:ClientReturns true if this client has been started and is still running. -
waitForConnected
protected void waitForConnected() -
isConnected
public boolean isConnected()Description copied from interface:ClientReturns true if this client is fully connected to the host.- Specified by:
isConnectedin interfaceClient
-
getId
public int getId()Description copied from interface:ClientReturns a unique ID for this client within the remote server or -1 if this client isn't fully connected to the server. -
getGameName
Description copied from interface:ClientReturns the 'game name' for servers to which this client should be able to connect. This should match the 'game name' set on the server or this client will be turned away.- Specified by:
getGameNamein interfaceClient
-
getVersion
public int getVersion()Description copied from interface:ClientReturns the game-specific version of the server this client should be able to connect to.- Specified by:
getVersionin interfaceClient
-
getServices
Description copied from interface:ClientReturns the manager for client services. Client services extend the functionality of the client.- Specified by:
getServicesin interfaceClient
-
send
Description copied from interface:ClientSends a message to the server.- Specified by:
sendin interfaceClient- Specified by:
sendin interfaceMessageConnection
-
send
Description copied from interface:ClientSends a message to the other end of the connection using the specified alternate channel.- Specified by:
sendin interfaceClient- Specified by:
sendin interfaceMessageConnection
-
send
-
close
public void close()Description copied from interface:ClientCloses this connection to the server. -
closeConnections
-
addClientStateListener
Description copied from interface:ClientAdds a listener that will be notified about connection state changes.- Specified by:
addClientStateListenerin interfaceClient
-
removeClientStateListener
Description copied from interface:ClientRemoves a previously registered connection listener.- Specified by:
removeClientStateListenerin interfaceClient
-
addMessageListener
Description copied from interface:ClientAdds a listener that will be notified when any message or object is received from the server.- Specified by:
addMessageListenerin interfaceClient
-
addMessageListener
Description copied from interface:ClientAdds a listener that will be notified when messages of the specified types are received.- Specified by:
addMessageListenerin interfaceClient
-
removeMessageListener
Description copied from interface:ClientRemoves a previously registered wildcard listener. This does not remove this listener from any type-specific registrations.- Specified by:
removeMessageListenerin interfaceClient
-
removeMessageListener
Description copied from interface:ClientRemoves a previously registered type-specific listener from the specified types.- Specified by:
removeMessageListenerin interfaceClient
-
addErrorListener
Description copied from interface:ClientAdds a listener that will be notified when any connection errors occur. If a client has no error listeners then the default behavior is to close the connection and provide an appropriate DisconnectInfo to any ClientStateListeners. If the application adds its own error listeners then it must take care of closing the connection itself.- Specified by:
addErrorListenerin interfaceClient
-
removeErrorListener
Description copied from interface:ClientRemoves a previously registered error listener.- Specified by:
removeErrorListenerin interfaceClient
-
fireConnected
protected void fireConnected() -
startServices
protected void startServices() -
fireDisconnected
-
handleError
Either calls the ErrorListener or closes the connection if there are no listeners. -
configureChannels
protected void configureChannels(long tempId, int[] ports) -
dispatch
-