public interface MessageTransferServer
This is the interface to the underlying network library that serializes and transfers the messages produced by this framework.
All methods defined in here are intended to be used by SynchronizeFxClient and not by the user.
Any implementation must be capable of transferring all classes in the package
de.saxsys.synchronizefx.core.metamodel.commands, the class java.util.UUID and all classes of the user
domain model that doesn't contain any Fields that extend Property. You may wan't the user to provide them
manually if your implementation hasn't any generic system to handle any Object that is thrown on it.
It is guaranteed that MessageTransferServer#setTopologyCallback(NetworkToTopologyCallbackServer) is only
called before start() and the send methods only after
start() (maybe multiple times). It is also guaranteed that no more methods are called
after shutdown() was called.
If you support user supplied serializers, please use the Serializer interface for them. This way serializers
are usable for multiple MessageTransferServer implementations.
This is the server side. For the client side see MessageTransferClient.
| Modifier and Type | Method and Description |
|---|---|
void |
onConnectFinished(Object client)
Called in response to
NetworkToTopologyCallbackServer.onConnect(Object) when the setup for the new client
has finished. |
void |
send(List<Object> messages,
Object client)
Sends messages to a single client.
|
void |
sendToAll(List<Object> messages)
Sends messages to all connected peers.
|
void |
sendToAllExcept(List<Object> messages,
Object nonReciver)
Sends a message to all peers except to
nonReciver. |
void |
setTopologyLayerCallback(NetworkToTopologyCallbackServer callback)
Sets the callback to the topology layer for events like incoming messages, new connections or errors.
|
void |
shutdown()
Disconnect all clients that are still connected an shut down the Server.
|
void |
start()
Starts the server and make it listen for new client connections.
|
void setTopologyLayerCallback(NetworkToTopologyCallbackServer callback)
callback - The callbackvoid start()
throws SynchronizeFXException
SynchronizeFXException - when the start up of the server failed.void onConnectFinished(Object client)
NetworkToTopologyCallbackServer.onConnect(Object) when the setup for the new client
has finished.
Ensure that send in this interface can take account of the new client before you return from this
method.client - The client which was set up.void sendToAll(List<Object> messages)
onConnectFinished(Object) has be
called for it so don't send the messages to clients where this method has not been called yet.messages - the messages to send. The messages don't need to be send all at once but their order must not be
changed.void send(List<Object> messages, Object client)
messages - the messages to send. The messages don't need to be send all at once but their order must not be
changed.client - the destination to which this method should be send. Only objects returned by
IncommingEventHandlerServer#recive(List, Object) as sender are valid destinations.void sendToAllExcept(List<Object> messages, Object nonReciver)
nonReciver.
In this context, a peer is connected only after onConnectFinished(Object) has be
called for it so don't send the messages to clients where this method has not been called yet.messages - The messages to be send. The messages don't need to be send all at once but their order must not
be changed.nonReciver - The client that should not receive the message.void shutdown()
Copyright © 2014 Saxonia Systems AG. All Rights Reserved.