public class GameBridgeUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
GameBridgeUtils.AcceptanceState |
static class |
GameBridgeUtils.NegotiationMode |
(package private) static class |
GameBridgeUtils.QuitState |
Modifier and Type | Field and Description |
---|---|
(package private) java.util.logging.Logger |
logger |
Constructor and Description |
---|
GameBridgeUtils(GameSpec spec)
Constructor for GameBridgeUtils.
|
Modifier and Type | Method and Description |
---|---|
void |
doGetHelper(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Method to implement HTTP GET.
|
void |
doPostHelper(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Method to implement HTTP POST.
|
(package private) GameBridgeUtils.AcceptanceState |
getAstate()
This method allows other classes in Core (namely the Mediator and VHRunner) to know whether or not the game is over due to mutual acceptance.
|
(package private) javax.servlet.http.HttpSession |
getHttpSession() |
(package private) GameBridgeUtils.NegotiationMode |
getNMode() |
(package private) GameBridgeUtils.QuitState |
getQstate()
This method allows other classes in Core (namely the Mediator and VHRunner) to know whether or not the game is over due to mutual quitting.
|
(package private) void |
handleClose() |
void |
onCloseHelper(javax.websocket.Session session,
javax.websocket.CloseReason cr)
Method that runs when the webpage is closed.
|
void |
onMessageHelper(javax.websocket.Session session,
java.lang.String msg,
boolean last)
Method that runs every time the webpage sends an event to GameBridge.
|
void |
onOpenHelper(javax.websocket.Session session,
javax.websocket.EndpointConfig config,
GeneralVH agent0,
GeneralVH agent1)
Method that runs when the webpage is opened.
|
(package private) void |
processEvent(Event e,
javax.websocket.Session session)
Processes an individual event and adds appropriate events to the history and/or the queue to be sent to opposing agent
|
(package private) void |
sendFinalNotification()
When one user FORMAL_END the game, notify the other in H-H mode
should only be used in NegotiationRoom class
When this function is used, the game is already ended internally
|
void |
setGameSpec(GameSpec spec)
Changes the game spec and resets several variables.
|
void |
setMultiplayer(boolean multi) |
void |
setNegotiationMode(GameBridgeUtils.NegotiationMode nMode) |
void |
setNRoom(NegotiationRoom nRoom) |
void |
setSessionOther(javax.servlet.http.HttpSession httpSession,
javax.websocket.Session session) |
public GameBridgeUtils(GameSpec spec)
spec
- The GameSpec for the first game to be played using this GBU.public void setGameSpec(GameSpec spec)
spec
- the new GameSpecpublic void onOpenHelper(javax.websocket.Session session, javax.websocket.EndpointConfig config, GeneralVH agent0, GeneralVH agent1) throws javax.mail.MessagingException
session
- The web session that was just opened.config
- agent0
- The user's agent. If this is null, then the user does not have an agent and will negotiate on her own behalf.agent1
- The opponent agent. This should never be null.javax.mail.MessagingException
public void onCloseHelper(javax.websocket.Session session, javax.websocket.CloseReason cr)
session
- The web session that closed.cr
- The reason the web session closed.void handleClose()
public void onMessageHelper(javax.websocket.Session session, java.lang.String msg, boolean last)
session
- the web session that sent the message.msg
- the message sent by the webpage.last
- Indicates whether or not this is the last of a series of messages. Currently unused.public void doPostHelper(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
request
- response
- javax.servlet.ServletException
java.io.IOException
public void doGetHelper(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
request
- response
- javax.servlet.ServletException
java.io.IOException
void processEvent(Event e, javax.websocket.Session session)
e
- session
- void sendFinalNotification()
GameBridgeUtils.AcceptanceState getAstate()
GameBridgeUtils.QuitState getQstate()
GameBridgeUtils.NegotiationMode getNMode()
javax.servlet.http.HttpSession getHttpSession()
public void setNRoom(NegotiationRoom nRoom)
public void setNegotiationMode(GameBridgeUtils.NegotiationMode nMode)
public void setSessionOther(javax.servlet.http.HttpSession httpSession, javax.websocket.Session session)
public void setMultiplayer(boolean multi)