Package com.bitheads.braincloud.services
Class LobbyService
java.lang.Object
com.bitheads.braincloud.services.LobbyService
- All Implemented Interfaces:
IServerCallback
public class LobbyService extends Object implements IServerCallback
Created by David St-Louis on 2018-07-04
-
Constructor Summary
Constructors Constructor Description LobbyService(BrainCloudClient client) -
Method Summary
Modifier and Type Method Description voidcancelFindRequest(String lobbyType, String cxId, IServerCallback callback)Cancel this members Find, Join and Searching of LobbiesvoidcreateLobby(String lobbyType, int rating, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, String settings, IServerCallback callback)Creates a new lobby.voidcreateLobbyWithPingData(String lobbyType, int rating, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, String settings, IServerCallback callback)Creates a new lobby with ping data Sends LOBBY_JOIN_SUCCESS message to the user, with full copy of lobby data Sends LOBBY_MEMBER_JOINED to all lobby members, with copy of member data Service Name - Lobby Service Operation - CREATE_LOBBY_WITH_PING_DATAvoidenableLogging(boolean isEnabled)voidfindLobby(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Finds a lobby matching the specified parameters.voidfindLobbyWithPingData(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Finds a lobby matching the specified parameters.voidfindOrCreateLobby(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, String settings, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Adds the caller to the lobby entry queue and will create a lobby if none are found.voidfindOrCreateLobbyWithPingData(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, String settings, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Adds the caller to the lobby entry queue and will create a lobby if none are found.voidgetLobbyData(String lobbyId, IServerCallback callback)Returns the data for the specified lobby, including member data.voidgetLobbyInstances(String lobbyType, String criteriaJson, IServerCallback callback)Gets a map keyed by rating of the visible lobby instances matching the given type and rating range.voidgetLobbyInstancesWithPingData(String lobbyType, String criteriaJson, IServerCallback callback)Gets a map keyed by rating of the visible lobby instances matching the given type and rating range.org.json.JSONObjectgetPingData()voidgetRegionsForLobbies(String[] in_lobbyTypes, IServerCallback callback)Retrieves the region settings for each of the given lobby types.voidjoinLobby(String lobbyId, boolean isReady, String extraJson, String teamCode, ArrayList<String> otherUserCxIds, IServerCallback callback)Causes the caller to join the specified lobby.voidjoinLobbyWithPingData(String lobbyId, boolean isReady, String extraJson, String teamCode, ArrayList<String> otherUserCxIds, IServerCallback callback)Causes the caller to join the specified lobby.voidleaveLobby(String lobbyId, IServerCallback callback)Causes the caller to leave the specified lobby.voidpingRegions(IServerCallback callback)voidremoveMember(String lobbyId, String cxId, IServerCallback callback)Evicts the specified user from the specified lobby.voidrunPingCallbacks()voidsendSignal(String lobbyId, String signalData, IServerCallback callback)Sends LOBBY_SIGNAL_DATA message to all lobby members.voidserverCallback(ServiceName serviceName, ServiceOperation serviceOperation, org.json.JSONObject jsonData)The serverCallback() method returns server data back to the layer interfacing with the BrainCloud library.voidserverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)Errors are returned back to the layer which is interfacing with the BrainCloud library through the serverError() callback.voidswitchTeam(String lobbyId, String toTeamCode, IServerCallback callback)Switches to the specified team (if allowed.) Sends LOBBY_MEMBER_UPDATED to all lobby members, with copy of member data Service Name - Lobby Service Operation - SWITCH_TEAMvoidupdateReady(String lobbyId, Boolean isReady, String extraJson, IServerCallback callback)Updates the ready status and extra json for the given lobby member.voidupdateSettings(String lobbyId, String settings, IServerCallback callback)Updates the ready status and extra json for the given lobby member.
-
Constructor Details
-
LobbyService
-
-
Method Details
-
enableLogging
public void enableLogging(boolean isEnabled) -
createLobby
public void createLobby(String lobbyType, int rating, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, String settings, IServerCallback callback)Creates a new lobby. Sends LOBBY_JOIN_SUCCESS message to the user, with full copy of lobby data Sends LOBBY_MEMBER_JOINED to all lobby members, with copy of member data Service Name - Lobby Service Operation - CREATE_LOBBY- Parameters:
lobbyType- The type of lobby to look for. Lobby types are defined in the portal.rating- The skill rating to use for finding the lobby. Provided as a separate parameter because it may not exactly match the user's rating (especially in cases where parties are involved).otherUserCxIds- Array of other users (i.e. party members) to add to the lobby as well. Will constrain things so that only lobbies with room for all players will be considered.isReady- Initial ready-status of this user.extraJson- Initial extra-data about this user.teamCode- Preferred team for this user, if applicable. Send "" or null for automatic assignment.settings- Configuration data for the room.callback- The callback handler
-
createLobbyWithPingData
public void createLobbyWithPingData(String lobbyType, int rating, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, String settings, IServerCallback callback)Creates a new lobby with ping data Sends LOBBY_JOIN_SUCCESS message to the user, with full copy of lobby data Sends LOBBY_MEMBER_JOINED to all lobby members, with copy of member data Service Name - Lobby Service Operation - CREATE_LOBBY_WITH_PING_DATA- Parameters:
lobbyType- The type of lobby to look for. Lobby types are defined in the portal.rating- The skill rating to use for finding the lobby. Provided as a separate parameter because it may not exactly match the user's rating (especially in cases where parties are involved).otherUserCxIds- Array of other users (i.e. party members) to add to the lobby as well. Will constrain things so that only lobbies with room for all players will be considered.isReady- Initial ready-status of this user.extraJson- Initial extra-data about this user.teamCode- Preferred team for this user, if applicable. Send "" or null for automatic assignment.settings- Configuration data for the room.callback- The callback handler
-
findLobby
public void findLobby(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Finds a lobby matching the specified parameters. Asynchronous - returns 200 to indicate that matchmaking has started. Service Name - Lobby Service Operation - FIND_LOBBY- Parameters:
lobbyType- The type of lobby to look for. Lobby types are defined in the portal.rating- The skill rating to use for finding the lobby. Provided as a separate parameter because it may not exactly match the user's rating (especially in cases where parties are involved).maxSteps- The maximum number of steps to wait when looking for an applicable lobby. Each step is ~5 seconds.algo- The algorithm to use for increasing the search scope.filterJson- Used to help filter the list of rooms to consider. Passed to the matchmaking filter, if configured.otherUserCxIds- Array of other users (i.e. party members) to add to the lobby as well. Will constrain things so that only lobbies with room for all players will be considered.isReady- Initial ready-status of this user.extraJson- Initial extra-data about this user.teamCode- Preferred team for this user, if applicable. Send "" or null for automatic assignmentcallback- The callback handler
-
findLobbyWithPingData
public void findLobbyWithPingData(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Finds a lobby matching the specified parameters. Asynchronous - returns 200 to indicate that matchmaking has started. But adds ping data to the call Service Name - Lobby Service Operation - FIND_LOBBY- Parameters:
lobbyType- The type of lobby to look for. Lobby types are defined in the portal.rating- The skill rating to use for finding the lobby. Provided as a separate parameter because it may not exactly match the user's rating (especially in cases where parties are involved).maxSteps- The maximum number of steps to wait when looking for an applicable lobby. Each step is ~5 seconds.algo- The algorithm to use for increasing the search scope.filterJson- Used to help filter the list of rooms to consider. Passed to the matchmaking filter, if configured.otherUserCxIds- Array of other users (i.e. party members) to add to the lobby as well. Will constrain things so that only lobbies with room for all players will be considered.isReady- Initial ready-status of this user.extraJson- Initial extra-data about this user.teamCode- Preferred team for this user, if applicable. Send "" or null for automatic assignmentcallback- The callback handler
-
findOrCreateLobby
public void findOrCreateLobby(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, String settings, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Adds the caller to the lobby entry queue and will create a lobby if none are found. Service Name - Lobby Service Operation - FIND_OR_CREATE_LOBBY- Parameters:
lobbyType- The type of lobby to look for. Lobby types are defined in the portal.rating- The skill rating to use for finding the lobby. Provided as a separate parameter because it may not exactly match the user's rating (especially in cases where parties are involved).maxSteps- The maximum number of steps to wait when looking for an applicable lobby. Each step is ~5 seconds.algo- The algorithm to use for increasing the search scope.filterJson- Used to help filter the list of rooms to consider. Passed to the matchmaking filter, if configured.otherUserCxIds- Array of other users (i.e. party members) to add to the lobby as well. Will constrain things so that only lobbies with room for all players will be considered.settings- Configuration data for the room.isReady- Initial ready-status of this user.extraJson- Initial extra-data about this user.teamCode- Preferred team for this user, if applicable. Send "" or null for automatic assignment.callback- The callback handler
-
findOrCreateLobbyWithPingData
public void findOrCreateLobbyWithPingData(String lobbyType, int rating, int maxSteps, String algo, String filterJson, ArrayList<String> otherUserCxIds, String settings, Boolean isReady, String extraJson, String teamCode, IServerCallback callback)Adds the caller to the lobby entry queue and will create a lobby if none are found. Service Name - Lobby Service Operation - FIND_OR_CREATE_LOBBY_WITH_PING_DATA- Parameters:
lobbyType- The type of lobby to look for. Lobby types are defined in the portal.rating- The skill rating to use for finding the lobby. Provided as a separate parameter because it may not exactly match the user's rating (especially in cases where parties are involved).maxSteps- The maximum number of steps to wait when looking for an applicable lobby. Each step is ~5 seconds.algo- The algorithm to use for increasing the search scope.filterJson- Used to help filter the list of rooms to consider. Passed to the matchmaking filter, if configured.otherUserCxIds- Array of other users (i.e. party members) to add to the lobby as well. Will constrain things so that only lobbies with room for all players will be considered.settings- Configuration data for the room.isReady- Initial ready-status of this user.extraJson- Initial extra-data about this user.teamCode- Preferred team for this user, if applicable. Send "" or null for automatic assignment.callback- The callback handler
-
getLobbyData
Returns the data for the specified lobby, including member data. Service Name - Lobby Service Operation - GET_LOBBY_DATA- Parameters:
lobbyId- Id of chosen lobby.callback- The callback handler
-
leaveLobby
Causes the caller to leave the specified lobby. If the user was the owner, a new owner will be chosen. If user was the last member, the lobby will be deleted. Service Name - Lobby Service Operation - LEAVE_LOBBY- Parameters:
lobbyId- Id of chosen lobby.callback- The callback handler
-
joinLobby
public void joinLobby(String lobbyId, boolean isReady, String extraJson, String teamCode, ArrayList<String> otherUserCxIds, IServerCallback callback)Causes the caller to join the specified lobby. Service Name - Lobby Service Operation - JOIN_LOBBY- Parameters:
lobbyId- Id of chosen lobby.isReady- initial ready status of this userextraJson- Initial extra-data about this userteamCode- specified team codeotherUserCxIds- Array fo other users (ie party members) to add to the lobby as well. Constrains things so only lobbies with room for all players will be considered.callback- The callback handler
-
joinLobbyWithPingData
public void joinLobbyWithPingData(String lobbyId, boolean isReady, String extraJson, String teamCode, ArrayList<String> otherUserCxIds, IServerCallback callback)Causes the caller to join the specified lobby. Service Name - Lobby Service Operation - JOIN_LOBBY_WITH_PING_DATA- Parameters:
lobbyId- Id of chosen lobby.isReady- initial ready status of this userextraJson- Initial extra-data about this userteamCode- specified team codeotherUserCxIds- Array fo other users (ie party members) to add to the lobby as well. Constrains things so only lobbies with room for all players will be considered.callback- The callback handler
-
removeMember
Evicts the specified user from the specified lobby. The caller must be the owner of the lobby. Service Name - Lobby Service Operation - REMOVE_MEMBER- Parameters:
lobbyId- Id of chosen lobby.cxId- Specified member to be removed from the lobby.callback- The callback handler
-
sendSignal
Sends LOBBY_SIGNAL_DATA message to all lobby members. Service Name - Lobby Service Operation - SEND_SIGNAL- Parameters:
lobbyId- Id of chosen lobby.signalData- Signal data to be sent.callback- The callback handler
-
switchTeam
Switches to the specified team (if allowed.) Sends LOBBY_MEMBER_UPDATED to all lobby members, with copy of member data Service Name - Lobby Service Operation - SWITCH_TEAM- Parameters:
lobbyId- Id of chosen lobby.toTeamCode- Specified team code.callback- The callback handler
-
updateReady
public void updateReady(String lobbyId, Boolean isReady, String extraJson, IServerCallback callback)Updates the ready status and extra json for the given lobby member. Service Name - Lobby Service Operation - UPDATE_READY- Parameters:
lobbyId- The type of lobby to look for. Lobby types are defined in the portal.isReady- Initial ready-status of this user.extraJson- Initial extra-data about this user.callback- The callback handler
-
updateSettings
Updates the ready status and extra json for the given lobby member. Service Name - Lobby Service Operation - UPDATE_SETTINGS- Parameters:
lobbyId- Id of the specfified lobby.settings- Configuration data for the room.callback- The callback handler
-
getLobbyInstances
Gets a map keyed by rating of the visible lobby instances matching the given type and rating range. Service Name - Lobby Service Operation - GET_LOBBY_INSTANCES- Parameters:
lobbyType- The type of lobby to look for.criteriaJson- A JSON string used to describe filter criteria.callback- The callback handler
-
getLobbyInstancesWithPingData
public void getLobbyInstancesWithPingData(String lobbyType, String criteriaJson, IServerCallback callback)Gets a map keyed by rating of the visible lobby instances matching the given type and rating range. Only lobby instances in the regions that satisfy the ping portion of the criteriaJson (based on the values provided in pingData) will be returned. Service Name - Lobby Service Operation - GET_LOBBY_INSTANCES_WITH_PING_DATA- Parameters:
lobbyType- The type of lobby to look for.criteriaJson- A JSON string used to describe filter criteria.callback- The callback handler
-
cancelFindRequest
Cancel this members Find, Join and Searching of Lobbies- Parameters:
lobbyType- Type of lobby being targeted.cxId- RTT connection id.callback- The callback handler
-
getRegionsForLobbies
Retrieves the region settings for each of the given lobby types.- Parameters:
in_lobbyTypes- Types of lobby being queried.callback- The callback handler
-
pingRegions
-
serverCallback
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, org.json.JSONObject jsonData)Description copied from interface:IServerCallbackThe serverCallback() method returns server data back to the layer interfacing with the BrainCloud library.- Specified by:
serverCallbackin interfaceIServerCallback- Parameters:
serviceName- - name of the requested serviceserviceOperation- - requested operationjsonData- - returned data from the server
-
serverError
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)Description copied from interface:IServerCallbackErrors are returned back to the layer which is interfacing with the BrainCloud library through the serverError() callback. A server error might indicate a failure of the client to communicate with the server after N retries.- Specified by:
serverErrorin interfaceIServerCallback- Parameters:
serviceName- - name of the requested serviceserviceOperation- - requested operationstatusCode- The error status return code (400, 403, 500, etc)reasonCode- The brainCloud reason code (see reason codes on apidocs site)jsonError- The error json string
-
runPingCallbacks
public void runPingCallbacks() -
getPingData
public org.json.JSONObject getPingData()
-