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(resourcesopt)
Asynchronously download resources for the experiment and register them with the server manager.
- For an experiment running locally: the root directory for the specified resources is that of index.html unless they are prepended with a protocol, such as http:// or https://.
- For an experiment running on the server: if no resources are specified, all files in the resources directory of the experiment are downloaded, otherwise we only download the specified resources. All resources are assumed local to index.html unless they are prepended with a protocol.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resources |
Array.<{name: string, path: string}> |
<optional> |
[] | the list of resources |
- 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>