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
FieldsModifier and TypeFieldDescriptionstatic PatternRegular expression to extract the session id out of a redirected Broadpeak URL. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSession(PlayerConfig config) Create and adds the a sessionvoidclear()Removes all Sessionsbooleancontains(PlayerConfig config) static StringgetSessionByConfig(PlayerConfig config) Returns the Session which contains the providedPlayerConfigmaybeUpdateUrl(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.voidonCurrentSessionChanged(SessionWrapper newSession) voidremoveSession(SessionWrapper session) Removes the provided sessionvoidrenew(SessionWrapper wrapper) intsize()
-
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:
BroadpeakSessionExceptionIOException
-
onCurrentSessionChanged
-
extractBroadpeakToken
-