import { Connection } from './Connection'; import { ConnectionProperties } from './ConnectionProperties'; import { OpenVidu } from './OpenVidu'; import { Publisher } from './Publisher'; import { SessionProperties } from './SessionProperties'; import { TokenOptions } from './TokenOptions'; export declare class Session { private ov; /** * Unique identifier of the Session */ sessionId: string; /** * Timestamp when this session was created, in UTC milliseconds (ms since Jan 1, 1970, 00:00:00 UTC) */ createdAt: number; /** * Properties defining the session */ properties: SessionProperties; /** * Array of Connections to the Session. This property always initialize as an empty array and * **will remain unchanged since the last time method {@link Session.fetch} or {@link OpenVidu.fetch} was called**. * Exceptions to this rule are: * * - Calling {@link Session.createConnection} automatically adds the new Connection object to the local collection. * - Calling {@link Session.forceUnpublish} automatically updates each affected local Connection object. * - Calling {@link Session.forceDisconnect} automatically updates each affected local Connection object. * - Calling {@link Session.updateConnection} automatically updates the attributes of the affected local Connection object. * * To get the array of Connections with their current actual value, you must call {@link Session.fetch} or {@link OpenVidu.fetch} * before consulting property {@link connections} */ connections: Connection[]; /** * Array containing the active Connections of the Session. It is a subset of {@link Session.connections} array containing only * those Connections with property {@link Connection.status} to `active`. * * To get the array of active Connections with their current actual value, you must call {@link Session.fetch} or {@link OpenVidu.fetch} * before consulting property {@link activeConnections} */ activeConnections: Connection[]; /** * Whether the session is being recorded or not */ recording: boolean; /** * Whether the session is being broadcasted or not */ broadcasting: boolean; /** * @hidden */ constructor(ov: OpenVidu, propertiesOrJson?: any); /** * @deprecated Use {@link Session.createConnection} instead to get a {@link Connection} object. * * @returns A Promise that is resolved to the generated _token_ string if success and rejected with an * [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object if not */ generateToken(tokenOptions?: TokenOptions): Promise; /** * Creates a new Connection object associated to Session object and configured with * `connectionProperties`. Each user connecting to the Session requires a Connection. * The token string value to send to the client side is available at {@link Connection.token}. * * @returns A Promise that is resolved to the generated {@link Connection} object if success and rejected with an * [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object if not */ createConnection(connectionProperties?: ConnectionProperties): Promise; /** * Gracefully closes the Session: unpublishes all streams and evicts every participant * * @returns A Promise that is resolved if the session has been closed successfully and rejected with an * [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object if not */ close(): Promise; /** * Updates every property of the Session with the current status it has in OpenVidu Server. This is especially useful for accessing the list of * Connections of the Session ({@link Session.connections}, {@link Session.activeConnections}) and use those values to call {@link Session.forceDisconnect}, * {@link Session.forceUnpublish} or {@link Session.updateConnection}. * * To update all Session objects owned by OpenVidu object at once, call {@link OpenVidu.fetch} * * @returns A promise resolved to true if the Session status has changed with respect to the server, or to false if not. * This applies to any property or sub-property of the Session object */ fetch(): Promise; /** * Removes the Connection from the Session. This can translate into a forced eviction of a user from the Session if the * Connection had status `active` or into a token invalidation if no user had taken the Connection yet (status `pending`). * * In the first case, OpenVidu Browser will trigger the proper events in the client-side (`streamDestroyed`, `connectionDestroyed`, * `sessionDisconnected`) with reason set to `"forceDisconnectByServer"`. * * In the second case, the token of the Connection will be invalidated and no user will be able to connect to the session with it. * * This method automatically updates the properties of the local affected objects. This means that there is no need to call * {@link Session.fetch} or {@link OpenVidu.fetch}] to see the changes consequence of the execution of this method applied in the local objects. * * @param connection The Connection object to remove from the session, or its `connectionId` property * * @returns A Promise that is resolved if the Connection was successfully removed from the Session and rejected with an * [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object if not */ forceDisconnect(connection: string | Connection): Promise; /** * Forces some Connection to unpublish a Stream (identified by its `streamId` or the corresponding {@link Publisher} object owning it). * OpenVidu Browser will trigger the proper events on the client-side (`streamDestroyed`) with reason set to `"forceUnpublishByServer"`. * * You can get `publisher` parameter from {@link Connection.publishers} array ({@link Publisher.streamId} for getting each `streamId` property). * Remember to call {@link Session.fetch} or {@link OpenVidu.fetch} before to fetch the current actual properties of the Session from OpenVidu Server * * This method automatically updates the properties of the local affected objects. This means that there is no need to call * {@link Session.fetch} or {@link OpenVidu.fetch} to see the changes consequence of the execution of this method applied in the local objects. * * @param publisher The Publisher object to unpublish, or its `streamId` property * * @returns A Promise that is resolved if the stream was successfully unpublished and rejected with an * [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object if not */ forceUnpublish(publisher: string | Publisher): Promise; /** * **This feature is part of OpenVidu * PRO * and * ENTERPRISE * editions** * * Updates the properties of a Connection with a {@link ConnectionProperties} object. * Only these properties can be updated: * * - {@link ConnectionProperties.role} * - {@link ConnectionProperties.record} * * This method automatically updates the properties of the local affected objects. This means that there is no need to call * {@link Session.fetch} or {@link OpenVidu.fetch} to see the changes consequence of the execution of this method applied in the local objects. * * The affected client will trigger one [ConnectionPropertyChangedEvent](/en/stable/api/openvidu-browser/classes/ConnectionPropertyChangedEvent.html) * for each modified property. * * @param connectionId The {@link Connection.connectionId} of the Connection object to modify * @param connectionProperties A new {@link ConnectionProperties} object with the updated values to apply * * @returns A Promise that is resolved to the updated {@link Connection} object if the operation was * successful and rejected with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object if not */ updateConnection(connectionId: string, connectionProperties: ConnectionProperties): Promise; /** * @hidden */ getSessionId(): string; /** * @hidden */ getSessionHttp(): Promise; /** * @hidden */ resetWithJson(json: any): Session; /** * @hidden */ equalTo(other: Session): boolean; /** * @hidden */ private removeCircularOpenViduReference; /** * @hidden */ private updateActiveConnectionsArray; /** * @hidden */ private sanitizeDefaultSessionProperties; /** * @hidden */ private formatMediaNodeObjectIfNecessary; }