Package io.cobrowse

Class Session

java.lang.Object
io.cobrowse.Session

public final class Session extends Object
  • Method Details

    • registerSessionListener

      public void registerSessionListener(@NonNull Session.Listener listener)
      Adds a listener to be notified of changes in a session
      Parameters:
      listener - Your listener implementation
    • removeSessionListener

      public void removeSessionListener(@NonNull Session.Listener listener)
      Removes a session change listener
      Parameters:
      listener - Your listener
    • code

      @Nullable public String code()
      The six digit code that can be shared with an agent to allow them to join the screen share. Note: this is only available for sessions in the "pending" state. Once an agent has joined the code will be null as it is no longer valid.
      Returns:
      The six digit code
    • id

      @Nullable public String id()
      The ID of a session. You will likely never need to access this.
      Returns:
      The Session ID
    • state

      @Nullable public String state()
      The state of the session. The session states transition as follows:

      pending ( → authorizing ) → active → ended

      The states mean:

      • pending - session has been created, but an agent or device has not yet joined
      • authorizing - confirmation prompt shown, waiting for the user to accept the session
      • active - the screen share session is in progress, frames are streaming
      • ended - the session is finished and can no longer be used or updated
      The authorizing step is optional as user consent may not always be required (configurable via the dashboard).
      Returns:
      The state (pending, authorizing, active, or ended)
      See Also:
    • update

      public void update(@Nullable Map<String,Object> params, @Nullable Callback<Error,Session> callback)
    • agent

      @Nullable public Agent agent()
      Gets the basic information about the support agent in the session, or null if no agent has joined yet
      Returns:
      The agent information or null
    • setRemoteControl

      public void setRemoteControl(Session.RemoteControlState state, @Nullable Callback<Error,Session> callback)
    • remoteControl

      public Session.RemoteControlState remoteControl()
    • hasAgent

      public boolean hasAgent()
      An agent has joined the session
      Returns:
      An agent has joined
    • isPending

      public boolean isPending()
      Tests if the session is in a pending state (waiting for an agent, or device)
      Returns:
      Pending state
    • isAuthorizing

      public boolean isAuthorizing()
      Tests if the session is in a authorizing state (waiting for user consent)
      Returns:
      Authorizing state
    • isActive

      public boolean isActive()
      Tests if the session is in an active state
      Returns:
      Pending state
    • isEnded

      public boolean isEnded()
      Tests if the session is in an ended state (can no longer be used or updated)
      Returns:
      Pending state
    • activate

      public void activate(@Nullable Callback<Error,Session> callback)
      Transitions a session from pending or authorizing to active, allowing frames to start streaming. In order to activate a session, some conditions must be met: 1. it must be in pending or authorizing state 2. an agent must have joined
      Parameters:
      callback - Called when the session is activated, or an error occurs
    • end

      public void end(@Nullable Callback<Error,Session> callback)
      Ends a session. Once ended frames will stop streaming and it can no longer be used.
      Parameters:
      callback - Called when the end request completes, or there is an error.
    • fullDevice

      @Deprecated public Boolean fullDevice()
      Deprecated.
      Checks whether the session is allowed to capture screens from outside the app.
      Returns:
      A value indicating whether the session is in full device state or not.
    • setFullDevice

      @Deprecated public void setFullDevice(boolean state, @Nullable Callback<Error,Session> callback)
      Deprecated.
      Whether the app should try to capture screens from outside the app or not.
      Parameters:
      state - New full device state.
      callback - Called when the end request completes, or there is an Error.
    • fullDeviceState

      public Session.FullDeviceState fullDeviceState()
      Checks whether the session is allowed to capture screens from outside the app.
      Returns:
      Session full device state.
    • setFullDeviceState

      public void setFullDeviceState(Session.FullDeviceState state, @Nullable Callback<Error,Session> callback)
      Whether the app should try to capture screens from outside the app or not.
      Parameters:
      state - New full device state.
      callback - Called when the end request completes, or there is an Error.
    • setCapabilities

      public void setCapabilities(@NonNull String[] capabilities, @Nullable Callback<Error,Session> callback)
      Sets the available capabilities for the session.
      Parameters:
      capabilities - Array of capability keys to enable.
      callback - A callback containing the updated session, or an error.