public interface NetcodeClient
MessageHandler is defined it gets invoked. If no such handler is
specified the messages enter the message queue for synchronous reception
using receive() or tryReceive().
The client can be switched between synchronous and asynchronous operation at
any time. When switching from synchronous to asynchronous mode all the
messages from the synchronous message queue are pushed into the message
handler. During this phase it is possible that messages arrive out of order
or multiple concurrent invocations of the handler exit. It is therefore
recommended to avoid frequent mode switching. Threads blocked in
receive() during the transition to asynchronous operation remain
blocked indefinitely.
Channel events can only be processed asynchronously. For this a
ChannelEventHandler must be specified.NetcodeClientFactory| Modifier and Type | Method and Description |
|---|---|
void |
disconnect()
Disconnect and terminate the client.
|
ChannelConfiguration |
getChannelConfiguration()
Get the configuration of the connected channel.
|
java.lang.String |
getUserId()
Get the userId of this client.
|
java.lang.String[] |
getUsers()
Get a list of all members of the channel.
|
Message |
receive()
Receive the next message synchronously and wait if no message is ready.
|
void |
send(java.io.Serializable payload)
Send the given object to all members of the channel
|
void |
sendPrivately(java.lang.String userId,
java.io.Serializable payload)
Send the given object to the member of the channel with the given userId.
|
void |
setEventHandler(ChannelEventHandler handler) |
void |
setMessageHandler(MessageHandler handler) |
Message |
tryReceive()
Receive the next message synchronously if it exists.
|
void disconnect()
throws java.io.IOException
java.io.IOExceptionvoid send(java.io.Serializable payload)
void sendPrivately(java.lang.String userId,
java.io.Serializable payload)
java.lang.String getUserId()
ChannelConfiguration getChannelConfiguration()
java.lang.String[] getUsers()
void setMessageHandler(MessageHandler handler)
void setEventHandler(ChannelEventHandler handler)
Message receive() throws java.lang.InterruptedException
MessageHandler is present
the call will block indefinitely.java.lang.InterruptedExceptionMessage tryReceive()
null.Copyright © 2018. All Rights Reserved.