You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.4 KiB
60 lines
1.4 KiB
import AppClass from '../../lifecycle/AppClass.ts'
|
|
import SessionInterface, {SessionData} from './SessionInterface.ts'
|
|
|
|
/**
|
|
* Abstract base-class for the request's session.
|
|
* @extends AppClass
|
|
* @implements SessionInterface
|
|
*/
|
|
export default abstract class Session extends AppClass implements SessionInterface {
|
|
/**
|
|
* Get the unique identifier for this session.
|
|
* @return string
|
|
*/
|
|
public abstract get_key(): string
|
|
|
|
/**
|
|
* Set the unique identifier for this session.
|
|
* @param {string} key
|
|
*/
|
|
public abstract set_key(key: string): void
|
|
|
|
/**
|
|
* Persist the session to its storage backend.
|
|
* @return Promise<void>
|
|
*/
|
|
public abstract async persist(): Promise<void>
|
|
|
|
/**
|
|
* Get the session data.
|
|
* @return SessionData
|
|
*/
|
|
public abstract get_data(): SessionData
|
|
|
|
/**
|
|
* Set the session data.
|
|
* @param {SessionData} data
|
|
*/
|
|
public abstract set_data(data: SessionData): void
|
|
|
|
/**
|
|
* Get the session attribute by key.
|
|
* @param {string} key
|
|
* @return any
|
|
*/
|
|
public abstract get_attribute(key: string): any
|
|
|
|
/**
|
|
* Set the session attribute by key.
|
|
* @param {string} key
|
|
* @param {any} value
|
|
*/
|
|
public abstract set_attribute(key: string, value: any): void
|
|
|
|
/**
|
|
* Initialize the session in its backend.
|
|
* @return Promise<void>
|
|
*/
|
|
public abstract async init_session(): Promise<void>
|
|
}
|