Package com.jme3.network.base
Class DefaultServer
java.lang.Object
com.jme3.network.base.DefaultServer
- All Implemented Interfaces:
- Server
A default implementation of the Server interface that delegates
  its network connectivity to kernel.Kernel.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classprotected classprotected class
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintaddChannel(int port) Adds an alternate channel to the server, using the specified port.voidaddConnectionListener(ConnectionListener listener) Adds a listener that will be notified when new hosted connections arrive.voidaddMessageListener(MessageListener<? super HostedConnection> listener) Adds a listener that will be notified when any message or object is received from one of the clients.voidaddMessageListener(MessageListener<? super HostedConnection> listener, Class... classes) Adds a listener that will be notified when messages of the specified types are received from one of the clients.protected voidvoidbroadcast(int channel, Filter<? super HostedConnection> filter, Message message) Sends the specified message over the specified alternate channel to all connected clients that match the filter.voidbroadcast(Filter<? super HostedConnection> filter, Message message) Sends the specified message to all connected clients that match the filter.voidSends the specified message to all connected clients.protected voidcheckChannel(int channel) voidclose()Closes all client connections, stops and running processing threads, and closes the host connection.protected voidprotected voiddispatch(HostedConnection source, Message m) protected voidprotected voidprotected intgetConnection(int id) Retrieves a hosted connection by ID.protected HostedConnectiongetConnection(Endpoint endpoint) Retrieves a read-only collection of all currently connected connections.Returns the 'game name' for this server.Returns the manager for hosted services.intReturns the game-specific version of this server used for detecting mismatched clients.booleanReturns true if the server has active connections at the time of this call.booleanReturns true if the server has been started.protected voidprotected voidvoidremoveConnectionListener(ConnectionListener listener) Removes a previously registered connection listener.voidremoveMessageListener(MessageListener<? super HostedConnection> listener) Removes a previously registered wildcard listener.voidremoveMessageListener(MessageListener<? super HostedConnection> listener, Class... classes) Removes a previously registered type-specific listener from the specified types.voidstart()Start the server so that it will begin accepting new connections and processing messages.
- 
Constructor Details- 
DefaultServer
 
- 
- 
Method Details- 
addStandardServicesprotected void addStandardServices()
- 
getGameNameDescription copied from interface:ServerReturns the 'game name' for this server. This should match the 'game name' set on connecting clients or they will be turned away.- Specified by:
- getGameNamein interface- Server
 
- 
getVersionpublic int getVersion()Description copied from interface:ServerReturns the game-specific version of this server used for detecting mismatched clients.- Specified by:
- getVersionin interface- Server
 
- 
getServicesDescription copied from interface:ServerReturns the manager for hosted services. Hosted services extend the functionality of the server.- Specified by:
- getServicesin interface- Server
 
- 
addChannelpublic int addChannel(int port) Description copied from interface:ServerAdds an alternate channel to the server, using the specified port. This is an entirely separate connection where messages are sent and received in parallel to the two primary default channels. All channels must be added before the connection is started. Returns the ID of the created channel for use when specifying the channel in send or broadcast calls. The ID is returned entirely out of convenience since the IDs are predictably incremented. The first channel is 0, second is 1, and so on.- Specified by:
- addChannelin interface- Server
 
- 
checkChannelprotected void checkChannel(int channel) 
- 
startpublic void start()Description copied from interface:ServerStart the server so that it will begin accepting new connections and processing messages.
- 
isRunningpublic boolean isRunning()Description copied from interface:ServerReturns true if the server has been started.
- 
closepublic void close()Description copied from interface:ServerCloses all client connections, stops and running processing threads, and closes the host connection.
- 
broadcastDescription copied from interface:ServerSends the specified message to all connected clients.
- 
broadcastDescription copied from interface:ServerSends the specified message to all connected clients that match the filter. If no filter is specified then this is the same as calling broadcast(message) and the message will be delivered to all connections.Examples: // Broadcast to connections: conn1, conn2, and conn3 server.broadcast( Filters.in( conn1, conn2, conn3 ), message ); // Broadcast to all connections exception source server.broadcast( Filters.notEqualTo( source ), message );
- 
broadcastDescription copied from interface:ServerSends the specified message over the specified alternate channel to all connected clients that match the filter. If no filter is specified then this is the same as calling broadcast(message) and the message will be delivered to all connections.Examples: // Broadcast to connections: conn1, conn2, and conn3 server.broadcast( Filters.in( conn1, conn2, conn3 ), message ); // Broadcast to all connections exception source server.broadcast( Filters.notEqualTo( source ), message );
- 
getConnectionDescription copied from interface:ServerRetrieves a hosted connection by ID.- Specified by:
- getConnectionin interface- Server
 
- 
hasConnectionspublic boolean hasConnections()Description copied from interface:ServerReturns true if the server has active connections at the time of this call.- Specified by:
- hasConnectionsin interface- Server
 
- 
getConnectionsDescription copied from interface:ServerRetrieves a read-only collection of all currently connected connections.- Specified by:
- getConnectionsin interface- Server
 
- 
addConnectionListenerDescription copied from interface:ServerAdds a listener that will be notified when new hosted connections arrive.- Specified by:
- addConnectionListenerin interface- Server
 
- 
removeConnectionListenerDescription copied from interface:ServerRemoves a previously registered connection listener.- Specified by:
- removeConnectionListenerin interface- Server
 
- 
addMessageListenerDescription copied from interface:ServerAdds a listener that will be notified when any message or object is received from one of the clients.Note about MessageListener multithreading: on the server, message events may be delivered by more than one thread depending on the server implementation used. Listener implementations should treat their shared data structures accordingly and set them up for multithreaded access. The only threading guarantee is that for a single HostedConnection, there will only ever be one thread at a time and the messages will always be delivered to that connection in the order that they were delivered. This is the only restriction placed upon server message dispatch pool implementations. - Specified by:
- addMessageListenerin interface- Server
 
- 
addMessageListenerpublic void addMessageListener(MessageListener<? super HostedConnection> listener, Class... classes) Description copied from interface:ServerAdds a listener that will be notified when messages of the specified types are received from one of the clients.- Specified by:
- addMessageListenerin interface- Server
 
- 
removeMessageListenerDescription copied from interface:ServerRemoves a previously registered wildcard listener. This does not remove this listener from any type-specific registrations.- Specified by:
- removeMessageListenerin interface- Server
 
- 
removeMessageListenerpublic void removeMessageListener(MessageListener<? super HostedConnection> listener, Class... classes) Description copied from interface:ServerRemoves a previously registered type-specific listener from the specified types.- Specified by:
- removeMessageListenerin interface- Server
 
- 
dispatch
- 
fireConnectionAdded
- 
fireConnectionRemoved
- 
getChannel
- 
registerClient
- 
getConnection
- 
removeConnecting
- 
connectionClosed
 
-