Package com.toxi.net
Class UDPSyncServer
java.lang.Object
com.toxi.net.UDPSyncServer
An MPE inspired synch server for networked multi-screen applications. All communication is realised via UDP. Clients are not requested to acknowledge every single packet received, but need to send a heart beat in a regular (configurable) interval. The server discards any data received from clients, so it doesn't matter what is being sent back. A single byte will suffice.
The server can be configured via CLI arguments and/or Java property files and can be connected to an existing logger. When run on from the commandline a console logger is automatically added.
- Author:
- Karsten Schmidt <info@postspectacular.com>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(TypedProperties config) Configures the server with settings using the passed-in properties.voidMain entry point for CLI.intintstatic voidvoidrun()Main server loop/state machine.voidsetListener(ServerListener listener) Attaches an event listener to the server.voidAttaches a logger to the server.voidsetMaxReceivePacketSize(int size) Sets the max.voidsetNumClients(int numClients) Sets the number of clients the server is expecting and initially waiting for to connect before any syncing begins.
-
Constructor Details
-
UDPSyncServer
public UDPSyncServer()
-
-
Method Details
-
main
-
execute
Main entry point for CLI.- Parameters:
args- command line arguments
-
configure
Configures the server with settings using the passed-in properties.- Parameters:
config-
-
run
public void run()Main server loop/state machine. Creates socket and handles syncing of connected clients. -
getMaxPacketSize
public int getMaxPacketSize()- Returns:
- Maximum size of UDP packets the server is able to receive
-
setMaxReceivePacketSize
public void setMaxReceivePacketSize(int size) Sets the max. size of UDP packets the server is able to receive- Parameters:
size-
-
getNumClients
public int getNumClients()- Returns:
- configured number of clients the server is expecting and initially waiting for to connect before any syncing begins.
-
setNumClients
public void setNumClients(int numClients) Sets the number of clients the server is expecting and initially waiting for to connect before any syncing begins.- Parameters:
numClients-
-
setLogger
Attaches a logger to the server.- Parameters:
logger-
-
setListener
Attaches an event listener to the server.- Parameters:
listener-
-