public class DefaultPlayerSession extends DefaultSession implements PlayerSession
PlayerSession interface is used to both
receive and send messages to a particular player using the
DefaultSession.onEvent(io.nadron.event.Event). Broadcasts from the
GameRoom are directly patched to the EventDispatcher which
listens on the room's MemoryChannel for events and in turn publishes
them to the listeners.| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultPlayerSession.PlayerSessionBuilder |
DefaultSession.SessionBuilderSession.Status| Modifier and Type | Field and Description |
|---|---|
protected GameRoom |
parentGameRoom
Each incoming connection is made to a game room.
|
protected Player |
player
Each session belongs to a Player.
|
protected Protocol |
protocol
This variable holds information about the type of binary communication
protocol to be used with this session.
|
creationTime, eventDispatcher, id, isShuttingDown, isUDPEnabled, isWriteable, lastReadWriteTime, sessionAttributes, status, tcpSender, udpSender| Modifier | Constructor and Description |
|---|---|
protected |
DefaultPlayerSession(DefaultPlayerSession.PlayerSessionBuilder playerSessionBuilder) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
GameRoom |
getGameRoom()
Each user session is attached to a game room.
|
Player |
getPlayer()
Each session is associated with a
Player. |
Protocol |
getProtocol()
Get the
Protocol associated with this session. |
void |
sendToGameRoom(Event event)
The event to be send to the
GameRoom to which the PlayerSession
belongs. |
void |
setGameRoom(GameRoom gameRoom)
Method used to set the game room for a particular session.
|
void |
setProtocol(Protocol protocol)
Set the network protocol on the user session.
|
String |
toString() |
addHandler, equals, getAttribute, getCreationTime, getEventDispatcher, getEventHandlers, getId, getLastReadWriteTime, getSessionAttributes, getStatus, getTcpSender, getUdpSender, hashCode, isConnected, isShuttingDown, isUDPEnabled, isWriteable, onEvent, removeAttribute, removeHandler, setAttribute, setId, setLastReadWriteTime, setStatus, setTcpSender, setUDPEnabled, setUdpSender, setWriteableclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddHandler, getAttribute, getCreationTime, getEventDispatcher, getEventHandlers, getId, getLastReadWriteTime, getStatus, getTcpSender, getUdpSender, isConnected, isShuttingDown, isUDPEnabled, isWriteable, onEvent, removeAttribute, removeHandler, setAttribute, setId, setStatus, setTcpSender, setUDPEnabled, setUdpSender, setWriteableprotected final Player player
protected GameRoom parentGameRoom
protected Protocol protocol
protected DefaultPlayerSession(DefaultPlayerSession.PlayerSessionBuilder playerSessionBuilder)
public Player getPlayer()
PlayerSessionPlayer. This is the actual
human or machine using this session.getPlayer in interface PlayerSessionpublic GameRoom getGameRoom()
PlayerSessiongetGameRoom in interface PlayerSessionpublic void setGameRoom(GameRoom gameRoom)
PlayerSessionsetGameRoom in interface PlayerSessiongameRoom - The gameRoom object to set.public Protocol getProtocol()
PlayerSessionProtocol associated with this session.getProtocol in interface PlayerSessionpublic void setProtocol(Protocol protocol)
PlayerSessionsetProtocol in interface PlayerSessionprotocol - The Protocol to set.public void close()
close in interface Sessionclose in class DefaultSessionpublic void sendToGameRoom(Event event)
PlayerSessionGameRoom to which the PlayerSession
belongs. Behavior is unspecified if message is sent when a room change is
taking place.sendToGameRoom in interface PlayerSessionevent - The event to send to the GameRoomCopyright © 2013. All Rights Reserved.