new ServerManager(options)
This manager handles all communications between the experiment running in the participant's browser and the remote PsychoJS manager running on the pavlovia.org server, in an asynchronous manner.
It is responsible for reading the configuration file of an experiment, for opening and closing a session, for listing and downloading resources, and for uploading results and log.
Note: The Server Manager uses Promises to deal with asynchronicity, is mostly called by PsychoJS, and is not exposed to the experiment code.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Extends
- PsychObject
Members
(readonly) Event :Symbol
Server event
A server event is emitted by the manager to inform its listeners of either a change of status, or of a resource related event (e.g. download started, download is completed).
Type:
- Symbol
- Source:
(readonly) SaveFormat :Symbol
Experiment result format
Type:
- Symbol
- Source:
(readonly) Status :Symbol
Server status
Type:
- Symbol
- Source:
Methods
(private) _downloadRegisteredResources()
Download the resources previously registered.
Note: we use the preloadjs library.
- Source:
(private) _listResources()
List the resources available to the experiment.
- Source:
closeSession(isCompletedopt) → {Promise.<ServerManager.CloseSessionPromise>}
Close the session for this experiment on the remote PsychoJS manager.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
isCompleted |
boolean |
<optional> |
false | whether or not the experiment was completed |
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.CloseSessionPromise>
downloadResources()
Asynchronously download the resources of the experiment from the remote PsychoJS manager and register them with the server manager.
- Source:
getConfiguration(configURL) → {Promise.<ServerManager.GetConfigurationPromise>}
Read the configuration file for the experiment.
Parameters:
Name | Type | Description |
---|---|---|
configURL |
string | the URL of the configuration file |
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.GetConfigurationPromise>
getResource(name) → {Object}
Get the value of a resource.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | of the requested resource |
- Source:
Throws:
-
exception if no resource with that name has previously been registered
- Type
- Object.<string, *>
Returns:
value of the resource
- Type
- Object
openSession() → {Promise.<ServerManager.OpenSessionPromise>}
Open a session for this experiment on the remote PsychoJS manager.
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.OpenSessionPromise>
resetStatus() → {ServerManager.Status.READY}
Reset the resource manager status to ServerManager.Status.READY.
- Source:
Returns:
the new status
setStatus()
Set the resource manager status.
- Source:
uploadData(key, value) → {Promise.<ServerManager.UploadDataPromise>}
Asynchronously upload experiment data to the remote PsychoJS manager.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | the data key (e.g. the name of .csv file) |
value |
string | the data value (e.g. a string containing the .csv header and records) |
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.UploadDataPromise>