Skip to main content

Class: Session

import {Session} from 'brainsatplay'

Constructors#

constructor#

+ new Session(username?: string, password?: string, appname?: string, access?: string, remoteHostURL?: string, localHostURL?: string): Session

let session = new Session();

Parameters#

NameTypeDefault value
usernamestring''
passwordstring''
appnamestring''
accessstring'public'
remoteHostURLstring'http://server.brainsatplay.com'
localHostURLstring'http://localhost:8000'

Returns: Session

Defined in: src/Session.js:69

Properties#

atlas#

atlas: DataAtlas


devices#

devices: any[]


info#

info: object

Type declaration#

NameType
authobject
auth.accessstring
auth.appnamestring
auth.authenticatedboolean
auth.passwordstring
auth.urlURL
auth.usernamestring
connectionsnever[]
localHostURLstring
nDevicesnumber
remoteHostURLstring
subscribedboolean

socket#

socket: undefined | null | WebSocket


state#

state: StateManager


streamObj#

streamObj: streamSession


subscribed#

subscribed: undefined | boolean

Methods#

addAnalysisMode#

addAnalysisMode(name?: string): void

Parameters#

NameTypeDefault value
namestring''

Returns: void

Defined in: src/Session.js:362

addAnalysisMode(mode?: string, deviceName?: any, n?: number): void

Parameters#

NameTypeDefault value
modestring''
deviceNameany-
nnumber0

Returns: void

Defined in: src/Session.js:472


addAnalyzerFunc#

addAnalyzerFunc(prop?: any, callback?: () => void): void

Parameters#

NameTypeDefault value
propanynull
callback() => void-

Returns: void

Defined in: src/Session.js:487


addStreamFunc#

addStreamFunc(name: any, callback: any, idx?: number): void

Parameters#

NameTypeDefault value
nameany-
callbackany-
idxnumber0

Returns: void

Defined in: src/Session.js:529


addStreamParams#

addStreamParams(params?: any[]): void

Parameters#

NameTypeDefault value
paramsany[][]

Returns: void

Defined in: src/Session.js:536


beginStream#

beginStream(streamParams?: any): void

Parameters#

NameType
streamParamsany

Returns: void

Defined in: src/Session.js:334


checkPathname#

checkPathname(pathname: any): any

Parameters#

NameType
pathnameany

Returns: any

Defined in: src/Session.js:1274


checkURL#

checkURL(url: any): any

Parameters#

NameType
urlany

Returns: any

Defined in: src/Session.js:1267


closeSocket#

closeSocket(): void

Returns: void

Defined in: src/Session.js:1249


configureStreamForGame#

configureStreamForGame(deviceTypes?: any[], streamParams?: any[]): boolean

Parameters#

NameTypeDefault value
deviceTypesany[][]
streamParamsany[][]

Returns: boolean

Defined in: src/Session.js:1179


connect#

connect(device?: string, analysis?: any, onconnect?: any, ondisconnect?: any, streaming?: boolean, streamParams?: any, useFilters?: boolean, pipeToAtlas?: boolean): undefined | false

method module:brainsatplay.Session.setLoginInfo

description Connect local device and add it. Use [reconnect()]{@link module:brainsatplay.Session.reconnect} if disconnecting and reconnecting device in same session.

Parameters#

NameTypeDefault valueDescription
devicestring"freeeeg32_2""freeeeg32", "freeeeg32_19", "muse", "notion"
analysisany-"eegfft", "eegcoherence", etc
onconnectany-Callback function on device connection. Subscribe to device outputs after connection completed.
ondisconnectany-Callback function on device disconnection. Unsubscribe from outputs after device is disconnected.
streamingbooleanfalseSet to stream to server (must be connected)
streamParamsany[]e.g. [['eegch','FP1','all']]
useFiltersbooleantrueFilter device output if it needs filtering (some hardware already applies filters so we may skip those).
pipeToAtlasbooleantrueSend data to atlas.

Returns: undefined | false

Defined in: src/Session.js:155


disconnect#

disconnect(deviceIdx?: any, ondisconnect?: any): void

method module:brainsatplay.Session.disconnect

description Disconnect local device.

Parameters#

NameTypeDescription
deviceIdxanyIndex of device.
ondisconnectanyCallback function on device disconnection.

Returns: void

Defined in: src/Session.js:247


endStream#

endStream(): void

Returns: void

Defined in: src/Session.js:342


getApp#

getApp(): any

Returns: any

Defined in: src/Session.js:562


getBrainstormData#

getBrainstormData(name: any): any[]

Parameters#

NameType
nameany

Returns: any[]

Defined in: src/Session.js:1134


getDevice#

getDevice(deviceNameOrType?: string, deviceIdx?: number): undefined

Parameters#

NameTypeDefault value
deviceNameOrTypestring'freeeeg32_2'
deviceIdxnumber0

Returns: undefined

Defined in: src/Session.js:347


getDeviceData#

getDeviceData(deviceType?: string, tag?: string, deviceIdx?: number): void

Parameters#

NameTypeDefault value
deviceTypestring'eeg'
tagstring'all'
deviceIdxnumber0

Returns: void

Defined in: src/Session.js:395


getGames#

getGames(appname?: string, onsuccess?: (newResult: any) => void): void

Parameters#

NameType
appnamestring
onsuccess(newResult: any) => void

Returns: void

Defined in: src/Session.js:822


getStreamData#

getStreamData(userOrAppname?: string, propname?: any): object

Parameters#

NameTypeDefault value
userOrAppnamestring''
propnameanynull

Returns: object

Defined in: src/Session.js:407


insertMultiplayerIntro#

insertMultiplayerIntro(applet: any): void

Parameters#

NameType
appletany

Returns: void

Defined in: src/Session.js:906


kickPlayerFromGame#

kickPlayerFromGame(gameId: any, userToKick: any, onsuccess?: (newResult: any) => void): void

Parameters#

NameType
gameIdany
userToKickany
onsuccess(newResult: any) => void

Returns: void

Defined in: src/Session.js:1161


login#

login(beginStream?: boolean, dict?: { access: string ; appname: string ; authenticated: boolean = false; password: string ; url: URL ; username: string }, baseURL?: string): Promise<undefined | WebSocket>

Parameters#

NameTypeDefault value
beginStreambooleanfalse
dictobject-
dict.accessstring-
dict.appnamestring-
dict.authenticatedbooleanfalse
dict.passwordstring-
dict.urlURL-
dict.usernamestring-
baseURLstring-

Returns: Promise<undefined | WebSocket>

Defined in: src/Session.js:579


loginWithGoogle#

loginWithGoogle(): Promise<any>

Returns: Promise<any>

Defined in: src/Session.js:566


loginWithRealm#

loginWithRealm(authResponse: any): Promise<any>

Parameters#

NameType
authResponseany

Returns: Promise<any>

Defined in: src/Session.js:570


makeConnectOptions#

makeConnectOptions(parentNode?: HTMLElement, onconnect?: any, ondisconnect?: any): void

method module:brainsatplay.Session.makeConnectOptions

description Generate DOM fragment with a selector for available devices.

Parameters#

NameTypeDescription
parentNodeHTMLElementParent node to insert fragment into.
onconnectanyCallback function on device connection.
ondisconnectanyCallback function on device disconnection.

Returns: void

Defined in: src/Session.js:262


onconnected#

onconnected(): void

Returns: void

Defined in: src/Session.js:223


onconnectionLost#

onconnectionLost(response: any): void

Parameters#

NameType
responseany

Returns: void

Defined in: src/Session.js:1253


ondisconnected#

ondisconnected(): void

Returns: void

Defined in: src/Session.js:225


processSocketMessage#

processSocketMessage(received?: string): void

Parameters#

NameTypeDefault value
receivedstring''

Returns: void

Defined in: src/Session.js:653


reconnect#

reconnect(deviceIdx?: any, onconnect?: any): void

method module:brainsatplay.Session.reconnect

description Reconnect a device that has already been added.

Parameters#

NameTypeDescription
deviceIdxanyIndex of device.
onconnectanyCallback function on device reconnection.

Returns: void

Defined in: src/Session.js:234


request#

request(body: any, method?: string, pathname?: string, baseURL?: string): Promise<any>

Parameters#

NameTypeDefault value
bodyany-
methodstring"POST"
pathnamestring''
baseURLstring-

Returns: Promise<any>

Defined in: src/Session.js:622


sendWSCommand#

sendWSCommand(command?: string, dict?: {}): void

Parameters#

NameTypeDefault value
commandstring''
dictobject{}

Returns: void

Defined in: src/Session.js:1239


setLoginInfo#

setLoginInfo(username?: string, password?: string, access?: string, appname?: string): void

method module:brainsatplay.Session.setLoginInfo

description Set user information.

Parameters#

NameTypeDefault valueDescription
usernamestring''Username.
passwordstring''Password.
accessstring'public'Access level ('public' or 'private').
appnamestring''Name of the app.

Returns: void

Defined in: src/Session.js:134


setupWebSocket#

setupWebSocket(auth?: { access: string ; appname: string ; authenticated: boolean = false; password: string ; url: URL ; username: string }): undefined | WebSocket

Parameters#

NameTypeDefault value
authobject-
auth.accessstring-
auth.appnamestring-
auth.authenticatedbooleanfalse
auth.passwordstring-
auth.urlURL-
auth.usernamestring-

Returns: undefined | WebSocket

Defined in: src/Session.js:729


signup#

signup(dict?: {}, baseURL?: string): Promise<any>

Parameters#

NameTypeDefault value
dictobject{}
baseURLstring-

Returns: Promise<any>

Defined in: src/Session.js:596


stopAnalysis#

stopAnalysis(name?: string): void

Parameters#

NameTypeDefault value
namestring''

Returns: void

Defined in: src/Session.js:379


streamAppData#

streamAppData(propname?: string, props?: {}, onData?: (newData: any) => void): string

Parameters#

NameTypeDefault value
propnamestring'data'
propsobject{}
onData(newData: any) => void-

Returns: string

Defined in: src/Session.js:502


subscribe#

subscribe(deviceName?: string, tag?: string, prop?: any, onData?: (newData: any) => void): undefined

Parameters#

NameTypeDefault value
deviceNamestring'eeg'
tagstring'FP1'
propanynull
onData(newData: any) => void-

Returns: undefined

Defined in: src/Session.js:426


subscribeToGame#

subscribeToGame(gameid?: string, spectating?: boolean, userToSubscribe?: string, onsuccess?: (newResult: any) => void): void

Parameters#

NameTypeDefault value
gameidstring-
spectatingbooleanfalse
userToSubscribestring-
onsuccess(newResult: any) => void-

Returns: void

Defined in: src/Session.js:845


subscribeToUser#

subscribeToUser(username?: string, userProps?: any[], userToSubscribe?: string, onsuccess?: (newResult: any) => void): void

Parameters#

NameTypeDefault value
usernamestring''
userPropsany[][]
userToSubscribestring-
onsuccess(newResult: any) => void-

Returns: void

Defined in: src/Session.js:773


unsubscribe#

unsubscribe(tag?: string, sub: any): void

Parameters#

NameTypeDefault value
tagstring'FP1'
subany-

Returns: void

Defined in: src/Session.js:463


unsubscribeAll#

unsubscribeAll(tag?: string): void

Parameters#

NameTypeDefault value
tagstring'FP1'

Returns: void

Defined in: src/Session.js:468


unsubscribeFromGame#

unsubscribeFromGame(gameId?: string, onsuccess?: (newResult: any) => void): void

Parameters#

NameTypeDefault value
gameIdstring''
onsuccess(newResult: any) => void-

Returns: void

Defined in: src/Session.js:886


unsubscribeFromUser#

unsubscribeFromUser(username?: string, userProps?: any, userToUnsubscribe?: string, onsuccess?: (newResult: any) => void): void

Parameters#

NameTypeDefault value
usernamestring''
userPropsanynull
userToUnsubscribestring-
onsuccess(newResult: any) => void-

Returns: void

Defined in: src/Session.js:803