1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00
psychojs/docs/module-core.ServerManager.html
2019-03-12 09:28:31 +01:00

1823 lines
22 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: ServerManager</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: ServerManager</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="module-core.html">core</a>.</span>ServerManager<span class="signature">(options)</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="ServerManager"><span class="type-signature"></span>new ServerManager<span class="signature">(options)</span><span class="type-signature"></span></h4>
<div class="description">
<p>This manager handles all communications between the experiment running in the participant's browser and the remote PsychoJS manager running on the <a href="http://pavlovia.org">pavlovia.org</a> server, <em>in an asynchronous manner</em>.</p>
<p>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.</p>
<p>Note: The Server Manager uses <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promises</a> to deal with asynchronicity, is mostly called by <a href="PsychoJS.html">PsychoJS</a>, and is not exposed to the experiment code.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>psychoJS</code></td>
<td class="type">
<span class="param-type"><a href="PsychoJS.html">PsychoJS</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">the PsychoJS instance</td>
</tr>
<tr>
<td class="name"><code>autoLog</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to log</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line18">line 18</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>PsychObject</li>
</ul>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="Event"><span class="type-signature">(readonly) </span>Event<span class="type-signature"> :Symbol</span></h4>
<div class="description">
Server event
<p>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).</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Symbol</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line515">line 515</a>
</li></ul></dd>
</dl>
<h4 class="name" id="SaveFormat"><span class="type-signature">(readonly) </span>SaveFormat<span class="type-signature"> :Symbol</span></h4>
<div class="description">
Experiment result format
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Symbol</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="data_ExperimentHandler.js.html">data/ExperimentHandler.js</a>, <a href="data_ExperimentHandler.js.html#line319">line 319</a>
</li></ul></dd>
</dl>
<h4 class="name" id="Status"><span class="type-signature">(readonly) </span>Status<span class="type-signature"> :Symbol</span></h4>
<div class="description">
Server status
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Symbol</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line554">line 554</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="_downloadRegisteredResources"><span class="type-signature">(private) </span>_downloadRegisteredResources<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Download the resources previously registered.
<p>Note: we use the <a href="https://www.createjs.com/preloadjs">preloadjs library</a>.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line402">line 402</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_listResources"><span class="type-signature">(private) </span>_listResources<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
List the resources available to the experiment.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line356">line 356</a>
</li></ul></dd>
</dl>
<h4 class="name" id="closeSession"><span class="type-signature"></span>closeSession<span class="signature">(isCompleted<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="ServerManager.html#.CloseSessionPromise">ServerManager.CloseSessionPromise</a>>}</span></h4>
<div class="description">
Close the session for this experiment on the remote PsychoJS manager.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>isCompleted</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not the experiment was completed</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line152">line 152</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the response
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="ServerManager.html#.CloseSessionPromise">ServerManager.CloseSessionPromise</a>></span>
</dd>
</dl>
<h4 class="name" id="downloadResources"><span class="type-signature"></span>downloadResources<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Asynchronously download the resources of the experiment from the remote PsychoJS manager and register them with the server manager.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line259">line 259</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getConfiguration"><span class="type-signature"></span>getConfiguration<span class="signature">(configURL)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="ServerManager.html#.GetConfigurationPromise">ServerManager.GetConfigurationPromise</a>>}</span></h4>
<div class="description">
Read the configuration file for the experiment.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>configURL</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the URL of the configuration file</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line61">line 61</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the response
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="ServerManager.html#.GetConfigurationPromise">ServerManager.GetConfigurationPromise</a>></span>
</dd>
</dl>
<h4 class="name" id="getResource"><span class="type-signature"></span>getResource<span class="signature">(name)</span><span class="type-signature"> &rarr; {Object}</span></h4>
<div class="description">
Get the value of a resource.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">of the requested resource</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line199">line 199</a>
</li></ul></dd>
</dl>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
exception if no resource with that name has previously been registered
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object.&lt;string, *></span>
</dd>
</dl>
</dt>
<dd></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
value of the resource
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="openSession"><span class="type-signature"></span>openSession<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="ServerManager.html#.OpenSessionPromise">ServerManager.OpenSessionPromise</a>>}</span></h4>
<div class="description">
Open a session for this experiment on the remote PsychoJS manager.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line94">line 94</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the response
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="ServerManager.html#.OpenSessionPromise">ServerManager.OpenSessionPromise</a>></span>
</dd>
</dl>
<h4 class="name" id="resetStatus"><span class="type-signature"></span>resetStatus<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="ServerManager.Status.html#.READY">ServerManager.Status.READY</a>}</span></h4>
<div class="description">
Reset the resource manager status to ServerManager.Status.READY.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line246">line 246</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the new status
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="ServerManager.Status.html#.READY">ServerManager.Status.READY</a></span>
</dd>
</dl>
<h4 class="name" id="setStatus"><span class="type-signature"></span>setStatus<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Set the resource manager status.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line220">line 220</a>
</li></ul></dd>
</dl>
<h4 class="name" id="uploadData"><span class="type-signature"></span>uploadData<span class="signature">(key, value)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="ServerManager.html#.UploadDataPromise">ServerManager.UploadDataPromise</a>>}</span></h4>
<div class="description">
Asynchronously upload experiment data to the remote PsychoJS manager.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the data key (e.g. the name of .csv file)</td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the data value (e.g. a string containing the .csv header and records)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_ServerManager.js.html">core/ServerManager.js</a>, <a href="core_ServerManager.js.html#line304">line 304</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the response
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;<a href="ServerManager.html#.UploadDataPromise">ServerManager.UploadDataPromise</a>></span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-core.html">core</a></li><li><a href="module-data.html">data</a></li><li><a href="module-sound.html">sound</a></li><li><a href="module-util.html">util</a></li><li><a href="module-visual.html">visual</a></li></ul><h3>Classes</h3><ul><li><a href="module-core.BuilderKeyResponse.html">BuilderKeyResponse</a></li><li><a href="module-core.EventManager.html">EventManager</a></li><li><a href="module-core.GUI.html">GUI</a></li><li><a href="module-core.MinimalStim.html">MinimalStim</a></li><li><a href="module-core.Mouse.html">Mouse</a></li><li><a href="module-core.PsychoJS.html">PsychoJS</a></li><li><a href="module-core.ServerManager.html">ServerManager</a></li><li><a href="module-core.Window.html">Window</a></li><li><a href="module-data.ExperimentHandler.html">ExperimentHandler</a></li><li><a href="module-data.TrialHandler.html">TrialHandler</a></li><li><a href="module-sound.Sound.html">Sound</a></li><li><a href="module-sound.TonePlayer.html">TonePlayer</a></li><li><a href="module-sound.TrackPlayer.html">TrackPlayer</a></li><li><a href="module-util.Clock.html">Clock</a></li><li><a href="module-util.Color.html">Color</a></li><li><a href="module-util.CountdownTimer.html">CountdownTimer</a></li><li><a href="module-util.EventEmitter.html">EventEmitter</a></li><li><a href="module-util.Logger.html">Logger</a></li><li><a href="module-util.MixinBuilder.html">MixinBuilder</a></li><li><a href="module-util.MonotonicClock.html">MonotonicClock</a></li><li><a href="module-util.PsychObject.html">PsychObject</a></li><li><a href="module-util.Scheduler.html">Scheduler</a></li><li><a href="module-visual.ImageStim.html">ImageStim</a></li><li><a href="module-visual.MovieStim.html">MovieStim</a></li><li><a href="module-visual.Rect.html">Rect</a></li><li><a href="module-visual.ShapeStim.html">ShapeStim</a></li><li><a href="module-visual.Slider.html">Slider</a></li><li><a href="module-visual.TextStim.html">TextStim</a></li><li><a href="module-visual.VisualStim.html">VisualStim</a></li></ul><h3>Mixins</h3><ul><li><a href="module-core.WindowMixin.html">WindowMixin</a></li><li><a href="module-util.ColorMixin.html">ColorMixin</a></li></ul><h3>Interfaces</h3><ul><li><a href="module-sound.SoundPlayer.html">SoundPlayer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Mar 12 2019 08:55:12 GMT+0100 (CET)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>