public class Session extends Object
Modifier and Type | Method and Description |
---|---|
void |
close()
Gracefully closes the Session: unpublishes all streams and evicts every
participant.
|
Connection |
createConnection()
Same as
createConnection(ConnectionProperties)
but with default ConnectionProperties values. |
Connection |
createConnection(ConnectionProperties connectionProperties)
Creates a new Connection object associated to Session object and configured
with
connectionProperties . |
long |
createdAt()
Timestamp when this session was created, in UTC milliseconds (ms since Jan 1,
1970, 00:00:00 UTC).
|
boolean |
fetch()
Updates every property of the Session with the current status it has in
OpenVidu Server.
|
void |
forceDisconnect(Connection connection)
Removes the Connection from the Session.
|
void |
forceDisconnect(String connectionId)
Same as
forceDisconnect(ConnectionProperties) but providing the
connectionId
instead of the Connection object. |
void |
forceUnpublish(Publisher publisher)
Forces some Connection to unpublish a Stream.
|
void |
forceUnpublish(String streamId)
Same as
forceUnpublish(Publisher) but providing the
streamId instead of
the Publisher object. |
String |
generateToken()
Deprecated.
Use
Session.createConnection()
instead to get a Connection
object. |
String |
generateToken(TokenOptions tokenOptions)
Deprecated.
Use
Session.createConnection(ConnectionProperties) instead to get a
Connection object. |
List<Connection> |
getActiveConnections()
Returns the list of active Connections of the Session.
|
Connection |
getConnection(String id)
Returns a Connection of the Session.
|
List<Connection> |
getConnections()
Returns all the Connections of the Session.
|
SessionProperties |
getProperties()
Returns the properties defining the session.
|
String |
getSessionId()
Gets the unique identifier of the Session.
|
boolean |
isBeingRecorded()
Returns whether the session is being recorded or not.
|
Connection |
updateConnection(String connectionId,
ConnectionProperties connectionProperties)
PRO Updates the properties of a Connection with a
ConnectionProperties object. |
public String getSessionId()
public long createdAt()
@Deprecated public String generateToken() throws OpenViduJavaClientException, OpenViduHttpException
Session.createConnection()
instead to get a Connection
object.OpenViduJavaClientException
OpenViduHttpException
@Deprecated public String generateToken(TokenOptions tokenOptions) throws OpenViduJavaClientException, OpenViduHttpException
Session.createConnection(ConnectionProperties)
instead to get a
Connection
object.OpenViduJavaClientException
OpenViduHttpException
public Connection createConnection() throws OpenViduJavaClientException, OpenViduHttpException
createConnection(ConnectionProperties)
but with default ConnectionProperties values.Connection
object.OpenViduJavaClientException
OpenViduHttpException
public Connection createConnection(ConnectionProperties connectionProperties) throws OpenViduJavaClientException, OpenViduHttpException
connectionProperties
. Each user connecting to the Session
requires a Connection. The token string value to send to the client side can
be retrieved with Connection.getToken()
.Connection
object.OpenViduJavaClientException
OpenViduHttpException
public void close() throws OpenViduJavaClientException, OpenViduHttpException
public boolean fetch() throws OpenViduJavaClientException, OpenViduHttpException
getActiveConnections()
) and use
those values to call
forceDisconnect(Connection)
,
forceUnpublish(Publisher)
or
updateConnection(String, ConnectionProperties)
.OpenVidu.fetch()
.OpenViduHttpException
OpenViduJavaClientException
public void forceDisconnect(Connection connection) throws OpenViduJavaClientException, OpenViduHttpException
active
, or into a token invalidation if no user had taken the
Connection yet (status pending
). streamDestroyed
, connectionDestroyed
,
sessionDisconnected
) with reason set to
"forceDisconnectByServer"
. Session.fetch()
or
OpenVidu.fetch()
to see the
changes consequence of the execution of this method applied in the local
objects.connection
- The Connection to removeOpenViduJavaClientException
OpenViduHttpException
public void forceDisconnect(String connectionId) throws OpenViduJavaClientException, OpenViduHttpException
forceDisconnect(ConnectionProperties)
but providing the
connectionId
instead of the Connection object.connectionId
- The identifier of the Connection object to removeOpenViduJavaClientException
OpenViduHttpException
public void forceUnpublish(Publisher publisher) throws OpenViduJavaClientException, OpenViduHttpException
streamDestroyed
) with
reason set to "forceUnpublishByServer"
. publisher
parameter with
getActiveConnections()
and then for
each Connection you can call
Connection.getPublishers()
. Remember to call
fetch()
before to fetch the current
actual properties of the Session from OpenVidu Server.Session.fetch()
or
OpenVidu.fetch()
to see the
changes consequence of the execution of this method applied in the local
objects.publisher
- The Publisher object to unpublishOpenViduJavaClientException
OpenViduHttpException
public void forceUnpublish(String streamId) throws OpenViduJavaClientException, OpenViduHttpException
forceUnpublish(Publisher)
but providing the
streamId
instead of
the Publisher object.streamId
- The identifier of the Publisher object to removeOpenViduJavaClientException
OpenViduHttpException
public Connection updateConnection(String connectionId, ConnectionProperties connectionProperties) throws OpenViduJavaClientException, OpenViduHttpException
ConnectionProperties
object. Only these
properties can be updated:
Session.fetch()
or
OpenVidu.fetch()
to see the
changes consequence of the execution of this method applied in the local
objects.connectionId
- The Connection to modifyconnectionProperties
- A ConnectionProperties object with the new values
to applyConnection
objectOpenViduJavaClientException
OpenViduHttpException
public Connection getConnection(String id)
Session.fetch()
or
OpenVidu.fetch()
.id
- The Connection to getConnection
object, or
null
if no Connection is found for param id
public List<Connection> getConnections()
Session.fetch()
or
OpenVidu.fetch()
.
The list of Connections will remain unchanged since the last time
method Session.fetch()
or
OpenVidu.fetch()
was
called. Exceptions to this rule are:
createConnection(ConnectionProperties)
automatically adds the new Connection
object to the local collection.forceUnpublish(String)
automatically updates each affected local Connection object.forceDisconnect(String)
automatically updates each affected local Connection object.updateConnection(String, ConnectionProperties)
automatically updates the attributes of the affected local Connection
object.Session.fetch()
or
OpenVidu.fetch()
.public List<Connection> getActiveConnections()
active
in response to
Connection.getStatus()
. This method only
returns the local available objects and does not query OpenVidu Server.
The list of active Connections will remain unchanged since the last
time method Session.fetch()
or OpenVidu.fetch()
was
called. Exceptions to this rule are:
createConnection(ConnectionProperties)
automatically adds the new Connection
object to the local collection.forceUnpublish(String)
automatically updates each affected local Connection object.forceDisconnect(String)
automatically updates each affected local Connection object.updateConnection(String, ConnectionProperties)
automatically updates the attributes of the affected local Connection
object.Session.fetch()
or OpenVidu.fetch()
OpenVidu.fetch()}.public boolean isBeingRecorded()
public SessionProperties getProperties()
Copyright © 2020 OpenVidu. All rights reserved.