Skip to main content

Class: Session

Constructors

new Session()

new Session(options): Session

A Session contains one or more activities. The session manages the start and stop of activities, and advancement to next activity

Parameters

options: SessionOptions

Returns

Session

Defined in

m2c2kit/packages/session/src/Session.ts:41

Properties

currentActivity?

optional currentActivity: Activity

Defined in

m2c2kit/packages/session/src/Session.ts:26


dataStores?

optional dataStores: IDataStore[]

Defined in

m2c2kit/packages/session/src/Session.ts:28


options

options: SessionOptions

Defined in

m2c2kit/packages/session/src/Session.ts:25

Accessors

nextActivity

Get Signature

get nextActivity(): undefined | Activity

Gets the next activity after the current one, or undefined if this is the last activity.

Returns

undefined | Activity

Defined in

m2c2kit/packages/session/src/Session.ts:672


uuid

Get Signature

get uuid(): string

Returns

string

Set Signature

set uuid(value): void

Parameters

value: string

Returns

void

Defined in

m2c2kit/packages/session/src/Session.ts:772

Methods

advanceToNextActivity()

advanceToNextActivity(): Promise<void>

Stops the current activity and advances to next activity in the session. If there is no activity after the current activity, throws error.

Returns

Promise<void>

Deprecated

Use goToNextActivity() instead.

Defined in

m2c2kit/packages/session/src/Session.ts:664


dictionaryDeleteItem()

dictionaryDeleteItem(key): boolean

Deletes an item value from the session's key-value dictionary.

Parameters

key: string

item key

Returns

boolean

true if the item was deleted, false if it did not exist

Remarks

The session dictionary is not persisted. It is available only during the actively running session. It is useful for storing temporary data to coordinate between activities.

Defined in

m2c2kit/packages/session/src/Session.ts:724


dictionaryGetItem()

dictionaryGetItem<T>(key): T

Gets an item value from the session's key-value dictionary.

Type Parameters

T extends SessionDictionaryValues

Parameters

key: string

item key

Returns

T

value of the item

Remarks

The session dictionary is not persisted. It is available only during the actively running session. It is useful for storing temporary data to coordinate between activities.

Defined in

m2c2kit/packages/session/src/Session.ts:710


dictionaryItemExists()

dictionaryItemExists(key): boolean

Determines if a key exists in the activity's key-value dictionary.

Parameters

key: string

item key

Returns

boolean

true if the key exists, false otherwise

Remarks

The session dictionary is not persisted. It is available only during the actively running session. It is useful for storing temporary data to coordinate between activities.

Defined in

m2c2kit/packages/session/src/Session.ts:738


dictionarySetItem()

dictionarySetItem(key, value): void

Saves an item to the session's key-value dictionary.

Parameters

key: string

item key

value: SessionDictionaryValues

item value

Returns

void

Remarks

The session dictionary is not persisted. It is available only during the actively running session. It is useful for storing temporary data to coordinate between activities.

Defined in

m2c2kit/packages/session/src/Session.ts:696


end()

end(): void

Declares the session ended and sends callback.

Returns

void

Defined in

m2c2kit/packages/session/src/Session.ts:523


goToActivity()

goToActivity(options): Promise<void>

Stops the current activity and goes to the activity with the provided id.

Parameters

options: GoToActivityOptions

Returns

Promise<void>

Defined in

m2c2kit/packages/session/src/Session.ts:554


goToNextActivity()

goToNextActivity(): Promise<void>

Stops the current activity and advances to next activity in the session. If there is no activity after the current activity, throws error.

Returns

Promise<void>

Defined in

m2c2kit/packages/session/src/Session.ts:644


init()

init(): Promise<void>

Asynchronously initializes the m2c2kit engine and loads assets

Returns

Promise<void>

Deprecated

Use Session.initialize() instead.

Defined in

m2c2kit/packages/session/src/Session.ts:238


initialize()

initialize(): Promise<void>

Asynchronously initializes the m2c2kit engine and loads assets

Returns

Promise<void>

Defined in

m2c2kit/packages/session/src/Session.ts:266


onActivityData()

onActivityData(callback, options?): void

Executes a callback when any activity in the session generates data.

Parameters

callback

function to execute.

options?: CallbackOptions

options for the callback.

Returns

void

Defined in

m2c2kit/packages/session/src/Session.ts:127


onEnd()

onEnd(callback, options?): void

Executes a callback when the session ends.

Parameters

callback

function to execute.

options?: CallbackOptions

options for the callback.

Returns

void

Defined in

m2c2kit/packages/session/src/Session.ts:114


onInitialize()

onInitialize(callback, options?): void

Executes a callback when the session initializes.

Parameters

callback

function to execute.

options?: CallbackOptions

options for the callback.

Returns

void

Defined in

m2c2kit/packages/session/src/Session.ts:84


onStart()

onStart(callback, options?): void

Executes a callback when the session starts.

Parameters

callback

function to execute.

options?: CallbackOptions

options for the callback.

Returns

void

Defined in

m2c2kit/packages/session/src/Session.ts:101


start()

start(): Promise<void>

Starts the session and starts the first activity.

Returns

Promise<void>

Defined in

m2c2kit/packages/session/src/Session.ts:500