new ServerManager(options)
This manager handles all communications between the experiment running in the participant's browser and 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, logs, and audio recordings.
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) ResourceStatus :Symbol
Resource status
Type:
- Symbol
- Source:
(readonly) SaveFormat :Symbol
Experiment result format
Type:
- Symbol
- Source:
(readonly) Status :Symbol
Server status
Type:
- Symbol
- Source:
Methods
(protected) _downloadResources(resources)
Download the specified resources.
Note: we use the preloadjs library.
Parameters:
Name | Type | Description |
---|---|---|
resources |
Set | a set of names of previously registered resources |
- Source:
closeSession(isCompletedopt, syncopt) → {Promise.<ServerManager.CloseSessionPromise>|void}
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 |
sync |
boolean |
<optional> |
false | whether or not to communicate with the server in a synchronous manner |
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.CloseSessionPromise> | void
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, errorIfNotDownloadedopt) → {Object}
Get the value of a resource.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | name of the requested resource | ||
errorIfNotDownloaded |
boolean |
<optional> |
false | whether or not to throw an exception if the resource status is not DOWNLOADED |
- Source:
Throws:
-
exception if no resource with that name has previously been registered
- Type
- Object.<string, *>
Returns:
value of the resource, or undefined if the resource has been registered
but not downloaded yet.
- Type
- Object
getResourceStatus(name) → {core.ServerManager.ResourceStatus}
Get the status 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:
status of the resource
- Type
- core.ServerManager.ResourceStatus
openSession() → {Promise.<ServerManager.OpenSessionPromise>}
Open a session for this experiment on the remote PsychoJS manager.
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.OpenSessionPromise>
prepareResources(resourcesopt)
Prepare resources for the experiment: register them with the server manager and possibly
start downloading them right away.
- 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.
- If resources is null, then we do not download any resources
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resources |
Array.<({name: string, path: string, download: boolean}|Symbol)> |
<optional> |
[] | the list of resources |
- Source:
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:
uploadAudio(audioBlob, tag) → {Promise.<ServerManager.UploadDataPromise>}
Asynchronously upload audio data to the pavlovia server.
Parameters:
Name | Type | Description |
---|---|---|
audioBlob |
Blob | the audio blob to be uploaded |
tag |
string | additional tag |
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.UploadDataPromise>
uploadData(key, value, syncopt) → {Promise.<ServerManager.UploadDataPromise>}
Asynchronously upload experiment data to the pavlovia server.
Parameters:
Name | Type | Attributes | Default | 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) | ||
sync |
boolean |
<optional> |
false | whether or not to communicate with the server in a synchronous manner |
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.UploadDataPromise>
uploadLog(logs, compressedopt) → {Promise.<ServerManager.UploadDataPromise>}
Asynchronously upload experiment logs to the pavlovia server.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
logs |
string | the base64 encoded, compressed, formatted logs | ||
compressed |
boolean |
<optional> |
false | whether or not the logs are compressed |
- Source:
Returns:
the response
- Type
- Promise.<ServerManager.UploadDataPromise>
waitForResources(resourcesopt)
Block the experiment until the specified resources have been downloaded.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resources |
Array.<{name: string, path: string}> |
<optional> |
[] | the list of resources |
- Source: