Session
The session objects are used to link the player instances together with the respective session instances.
Parameters
the receiver of the game message consumers, typically a player
the provider for outgoing message queues. One queue is allocated for each possible game server prot category.
Constructors
Properties
Functions
Clears all the remaining incoming and outgoing messages, releasing any buffers that were wrapped in a byte buffer holder. This function should be called on logout and whenever a reconnection happens, in order to get rid of any messages that got written to the session, but couldn't be flushed out in time before the session became inactive.
Flushes any queued messages to the client, if any exist. The flushing process takes place in the netty event loop, thus the calls to this function are non-blocking and fast. If not all packets were written due to writability constraints, this function will further be re-triggered when channel writability turns back to true, meaning this function can be called directly from the netty event loop, thus the check inside it.
Iterates through all the incoming packets over the last cycle and invokes the consumer with the receiver on them. If an exception is caught, it is propagated forward to the respective exception handler. If too many messages were received from the server during the last cycle, the decoder will have stopped accepting any new packets. If that was the case at the end of this function, the packet decoding will resume.
Queues a game message to be written to the client based on the message's defined category
Queues a game message to be written to the client based on the provided message category, in case one wishes to override the categories defined by the library
Requests the channel to be closed once there's nothing more to write out, and the channel has been flushed.
Sets a disconnection hook to be triggered if the connection to this channel is lost, allowing one to safely log the player out in such case. If the channel has already disconnected by the time this function is invoked, the hook will be executed immediately.