Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Local, structural mirror of the jsPsych multiplayer *adapter* contract.
*
* The real types live in jsPsych core (`packages/jspsych/src/modules/plugin-api/MultiplayerAPI.ts`),
* The real types live in jsPsych core (`packages/jspsych/src/modules/multiplayer/index.ts`),
* shipped via https://github.com/jspsych/jsPsych/pull/3694, which is not yet released — so the
* published `jspsych` package does not export `MultiplayerAdapter` / `GroupSessionData` /
* `Unsubscribe` yet. Rather than take a build-time dependency on an unmerged fork, this adapter
* implements the interface declared here, copied verbatim from that PR's `MultiplayerAPI.ts`. It is
* the single seam to re-verify once #3694 lands: at that point `implements MultiplayerAdapter` from
* `jspsych` should typecheck against this same shape.
* implements the interface declared here, copied verbatim from that PR's
* `modules/multiplayer/index.ts`. It is the single seam to re-verify once #3694 lands: at that
* point `implements MultiplayerAdapter` from `jspsych` should typecheck against this same shape.
*/

/** A group-session snapshot: participantId -> that participant's pushed data. */
Expand Down
8 changes: 4 additions & 4 deletions packages/adapter-multiplayer-jatos/src/multiplayer-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Local, structural mirror of the jsPsych multiplayer *adapter* contract.
*
* The real types live in jsPsych core (`packages/jspsych/src/modules/plugin-api/MultiplayerAPI.ts`),
* The real types live in jsPsych core (`packages/jspsych/src/modules/multiplayer/index.ts`),
* shipped via https://github.com/jspsych/jsPsych/pull/3694, which is not yet released — so the
* published `jspsych` package does not export `MultiplayerAdapter` / `GroupSessionData` /
* `Unsubscribe` yet. Rather than take a build-time dependency on an unmerged fork, this adapter
* implements the interface declared here, copied verbatim from that PR's `MultiplayerAPI.ts`. It is
* the single seam to re-verify once #3694 lands: at that point `implements MultiplayerAdapter` from
* `jspsych` should typecheck against this same shape.
* implements the interface declared here, copied verbatim from that PR's
* `modules/multiplayer/index.ts`. It is the single seam to re-verify once #3694 lands: at that
* point `implements MultiplayerAdapter` from `jspsych` should typecheck against this same shape.
*/

/** A group-session snapshot: participantId -> that participant's pushed data. */
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-multiplayer-local/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

- [#22](https://github.com/jspsych/jspsych-multiplayer/pull/22) [`2adafca`](https://github.com/jspsych/jspsych-multiplayer/commit/2adafcabe316cbbf588e9ba92805d52f9f09e417) Thanks [@htsukamoto5](https://github.com/htsukamoto5)! - Add `adapter-multiplayer-local`, a zero-infrastructure multiplayer adapter backed by `localStorage` and signalled cross-tab.

Swap it in for the JATOS adapter (`pluginAPI.connect(new LocalAdapter())`) to run multiplayer experiments by opening two browser tabs — no server, no account. It is a development/demo/tutorial/CI tool only: `localStorage` and its cross-tab signalling are same-origin, same-browser, same-machine, so it cannot cross devices, browsers, or machines and must not be used to collect real data.
Swap it in for the JATOS adapter (`jsPsych.multiplayer.connect(new LocalAdapter())`) to run multiplayer experiments by opening two browser tabs — no server, no account. It is a development/demo/tutorial/CI tool only: `localStorage` and its cross-tab signalling are same-origin, same-browser, same-machine, so it cannot cross devices, browsers, or machines and must not be used to collect real data.

It implements the same local `MultiplayerAdapter` mirror the JATOS adapter uses (no build-time dependency on the unreleased jsPsych#3694). The store is one key per participant (`mp:<session>:<participantId>`), reproducing JATOS's REPLACE-the-whole-slot semantics so plugins behave identically across adapters; a fresh session id per run (carried in the `?mp_session=` URL) namespaces keys to avoid stale "ghost" participants; and `push` self-notifies on a microtask so a tab's own waits resolve without reentrancy.
8 changes: 4 additions & 4 deletions packages/adapter-multiplayer-local/src/multiplayer-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* Local, structural mirror of the jsPsych multiplayer *adapter* contract.
*
* The real types live in jsPsych core (`packages/jspsych/src/modules/plugin-api/MultiplayerAPI.ts`),
* The real types live in jsPsych core (`packages/jspsych/src/modules/multiplayer/index.ts`),
* shipped via https://github.com/jspsych/jsPsych/pull/3694, which is not yet released — so the
* published `jspsych` package does not export `MultiplayerAdapter` / `GroupSessionData` /
* `Unsubscribe` yet. Rather than take a build-time dependency on an unmerged fork, this adapter
* implements the interface declared here, copied verbatim from that PR's `MultiplayerAPI.ts`. It is
* the single seam to re-verify once #3694 lands: at that point `implements MultiplayerAdapter` from
* `jspsych` should typecheck against this same shape.
* implements the interface declared here, copied verbatim from that PR's
* `modules/multiplayer/index.ts`. It is the single seam to re-verify once #3694 lands: at that
* point `implements MultiplayerAdapter` from `jspsych` should typecheck against this same shape.
*/

/** A group-session snapshot: participantId -> that participant's pushed data. */
Expand Down