import { BiDi } from '../../index'; import { CapabilitiesRequest, SessionNewResult, SessionStatusResult, SubscriptionRequest, SubscriptionType } from "./types"; /** * Class representing a session. */ export default class Session { _ws: BiDi; _events: SubscriptionType | undefined; _contexts: SubscriptionType | undefined; _capabilities: CapabilitiesRequest | undefined; /** * Create a session. * @param {BiDi} BidiConnection - BiDi Connection */ constructor(BidiConnection: BiDi); /** * Validates that all types in an array are strings. * @param {Array} array - An array of subscriptions. * @param {string} arrayName - Name of the array for error messages. * @throws {TypeError} if non-string types are present in the array. */ private validateStringTypes; /** * Manages subscriptions for events. Used for both subscribing and unsubscribing. * @private * @returns {Promise} Promise representing sending command for subscription/unsubscription. * @param parameters */ private manageSubscription; /** * Subscribes to specified events. * @returns {Promise} Promise representing sending command for subscription. * @param subscriptionRequest */ subscribe(subscriptionRequest: SubscriptionRequest): Promise; /** * Unsubscribes from specified events. * @returns {Promise} Promise representing sending command for unsubscription. * @param unsubscriptionType */ unsubscribe(unsubscriptionType: SubscriptionRequest): Promise; /** * Get status of session. * @return {Promise} Promise object represents the session status. */ get status(): Promise; /** * Create a new session * @param {CapabilitiesRequest} capabilities - The capabilities that the new session should have. * @return {Promise} Promise object represents the newly created session. * @throws {Error} When unable to create a session. */ new(capabilities: CapabilitiesRequest): Promise; /** * Ends the active session. * * Sends a command to the WebSocket to end the current session through the `session.end` method. * * @async * @returns {Promise} Promise that resolves if the session ends successfully, * rejects if the WebSocket fails to send the command. */ end(): Promise; }