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(org.menacheri.jetserver.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.SessionBuilder
Session.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, setWriteable
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addHandler, getAttribute, getCreationTime, getEventDispatcher, getEventHandlers, getId, getLastReadWriteTime, getStatus, getTcpSender, getUdpSender, isConnected, isShuttingDown, isUDPEnabled, isWriteable, onEvent, removeAttribute, removeHandler, setAttribute, setId, setStatus, setTcpSender, setUDPEnabled, setUdpSender, setWriteable
protected final Player player
protected GameRoom parentGameRoom
protected Protocol protocol
protected DefaultPlayerSession(DefaultPlayerSession.PlayerSessionBuilder playerSessionBuilder)
public Player getPlayer()
PlayerSession
Player
. This is the actual
human or machine using this session.getPlayer
in interface PlayerSession
public GameRoom getGameRoom()
PlayerSession
getGameRoom
in interface PlayerSession
public void setGameRoom(GameRoom gameRoom)
PlayerSession
setGameRoom
in interface PlayerSession
gameRoom
- The gameRoom object to set.public Protocol getProtocol()
PlayerSession
Protocol
associated with this session.getProtocol
in interface PlayerSession
public void setProtocol(Protocol protocol)
PlayerSession
setProtocol
in interface PlayerSession
protocol
- The Protocol
to set.public void close()
close
in interface Session
close
in class DefaultSession
public void sendToGameRoom(Event event)
PlayerSession
GameRoom
to which the PlayerSession
belongs. Behavior is unspecified if message is sent when a room change is
taking place.sendToGameRoom
in interface PlayerSession
event
- The event to send to the GameRoom
Copyright © 2013. All Rights Reserved.