Package com.castlabs.sdk.broadpeak
Class SessionManager
java.lang.Object
com.castlabs.sdk.broadpeak.SessionManager
Container for multiple
SessionApi
. Provides methods for indexing them by url and config
in a convenient and quick manner.
Note that URLs shall be unique. As otherwise a collision might occur.
-
Field Summary
Modifier and TypeFieldDescriptionstatic Pattern
Regular expression to extract the session id out of a redirected Broadpeak URL. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddSession
(PlayerConfig config) Create and adds the a sessionvoid
clear()
Removes all Sessionsboolean
contains
(PlayerConfig config) static String
getSessionByConfig
(PlayerConfig config) Returns the Session which contains the providedPlayerConfig
maybeUpdateUrl
(Request request) Updates the given URL in case it contains a token and it needs to be replaced by an updated one due to a renewal.void
onCurrentSessionChanged
(SessionWrapper newSession) void
removeSession
(SessionWrapper session) Removes the provided sessionvoid
renew
(SessionWrapper wrapper) int
size()
-
Field Details
-
TOKEN_URL_PATTERN
Regular expression to extract the session id out of a redirected Broadpeak URL. The default value is:Pattern.compile("bpk-token/([^/]+)/")
and can be customised if needed.
-
-
Constructor Details
-
SessionManager
public SessionManager(@NonNull com.castlabs.sdk.broadpeak.PlayerInfoApi infoApi)
-
-
Method Details
-
removeSession
Removes the provided session- Parameters:
session
- the session to remove
-
getSessionByConfig
Returns the Session which contains the providedPlayerConfig
- Parameters:
config
- the config for which to return the Session- Returns:
- the Session
-
getSessions
- Returns:
- all Sessions
-
clear
public void clear()Removes all Sessions -
size
public int size()- Returns:
- the number of sessions
-
contains
- Parameters:
config
- the config to look for- Returns:
- whether the provided configuration has a linked Session to it
-
renew
-
addSession
Create and adds the a session- Parameters:
config
- The PlayerConfig to create the session- Returns:
- The session that has been just created
-
maybeUpdateUrl
Updates the given URL in case it contains a token and it needs to be replaced by an updated one due to a renewal. In case the renewal hasn't yet been completed, it will wait for it.- Parameters:
request
- the request of which to update the URL- Throws:
BroadpeakSessionException
IOException
-
onCurrentSessionChanged
-
extractBroadpeakToken
-