public interface GameRoom
Modifier and Type | Method and Description |
---|---|
void |
afterSessionConnect(PlayerSession playerSession)
Method called after the session is created.
|
void |
close()
This method will close down the game room.
|
boolean |
connectSession(PlayerSession playerSession)
When a new user connects to the game, this method will be invoked to add
the incoming session to the game room.
|
PlayerSession |
createPlayerSession(Player player)
Method used to create a player session object.
|
boolean |
disconnectSession(PlayerSession session)
Remove a session from the existing list of user sessions.
|
String |
getGameRoomName() |
Game |
getParentGame()
Each game room belongs to a game.
|
Protocol |
getProtocol()
Each game room has a protocol attached to it.
|
Set<PlayerSession> |
getSessions()
Returns a list of sessions that is held by the game room.
|
GameStateManagerService |
getStateManager()
Every non trivial game will have some sort of state management service
going on.
|
void |
onLogin(PlayerSession playerSession)
Method called after the session is created.
|
void |
send(Event event)
Used to send an event to the GameRoom.
|
void |
sendBroadcast(NetworkEvent networkEvent)
Method used to send a broadcast message to all sessions in the group.
|
void |
setGameRoomName(String gameRoomName)
Sets the name of the game room.
|
void |
setParentGame(Game parentGame)
Used to set the parent game object of the game room.
|
void |
setProtocol(Protocol protocol)
Sets the protocol instance on the game room.
|
void |
setSessions(Set<PlayerSession> sessions)
Method used to set the set of user sessions to a particular game room.
|
void |
setStateManager(GameStateManagerService stateManager)
Method used to set the state manager for a game room.
|
PlayerSession createPlayerSession(Player player)
void onLogin(PlayerSession playerSession)
boolean connectSession(PlayerSession playerSession)
playerSession
- The incoming user session. If we are using netty, it would be
a Channel
object wrapped in a PlayerSession
.void afterSessionConnect(PlayerSession playerSession)
boolean disconnectSession(PlayerSession session)
session
- The session to be removed from the set.Set<PlayerSession> getSessions()
String getGameRoomName()
void setGameRoomName(String gameRoomName)
gameRoomName
- Game getParentGame()
void setParentGame(Game parentGame)
parentGame
- The game to which this game room belongs.GameStateManagerService getStateManager()
void setStateManager(GameStateManagerService stateManager)
stateManager
- Protocol getProtocol()
void setProtocol(Protocol protocol)
protocol
- The protocol instance to set.void setSessions(Set<PlayerSession> sessions)
sessions
- The set of sessions to be set.void send(Event event)
PlayerSession
s if required.
Implementations are generally expected to be async, so default
implementation would be to just patch incoming event to the
Session.onEvent(org.menacheri.jetserver.event.Event)
of the
GameRoom's session where the actual business logic can be applied.event
- The event to send to roomvoid sendBroadcast(NetworkEvent networkEvent)
DefaultPlayer
s
to the same state. This method will transmit messages using the delivery
guaranty provided in the NetworkEvent
.networkEvent
- The message that is to be broadcast to all user sessions of
this game roomvoid close()
Copyright © 2013. All Rights Reserved.