bespoke-synchro
Presentation Synchronizing for Bespoke.js
This bespoke plugin synchronises the current slide index between multiple clients.
By default only slides accessed on localhost can broadcast a new slide index to other slides.
Installation
$ npm install bespoke-synchro
This module should be installed with npm, since it's packaged with a necessary WebSocket mediator server
Usage
On the client side (options shown are defaults):
var bespoke = synchro = ; bespoke;
The bespoke-synchro plugin relies on a WebSocket mediator to interface between presentation instances (e.g. between each loaded presentation in a browser).
Enable/Disable
There may be certain circumstances where controlling the ability
to sending and/or receive synchronization packets is desirable.
The return value of synchro
comes with disable
, enable
and toggle
methods:
bespoke; document;
Each of the methods (disable
, enable
and toggle
)
have rx
(e.g. receive) and tx
(e.g. transmit), submethods.
Use these to control only one side of the interface
if slave synchrodisable;if master synchrodisable;
Mediator
In node (options shown are defaults)
var mediator =
The options supplied to mediator
are passed directly to
ws.Server
, see
https://github.com/websockets/ws/blob/master/doc/ws.md
Control
On both the client and server side a control
function can
be supplied to configure the decision mechanism for choosing
the clients that broadcast synchronization signals.
Client side contract is a function accepting origin
and socket
parameters, which must return an object with a local
property.
Absence of the object will cause a throw, absence of a local
property will result in an assumed false
value.
Server side contract is a function accepting origin
, socket
and clients
parameters, which must return an object containing
local
and primary
properties.
The primary control socket should stay consistent, it's used to broadcast the current page to newly connected clients. We have to choose one socket to do this, otherwise clients are hit multiple times.
Absence of the object will cause a throw, absence of a local
property will result in an assumed false
value, absence of
a primary
property will prevent clients from receiving the
current active slide upon loading.
Mediator executable
When bespoke-synchro
is installed globally, the mediator
can started via an executable:
npm install -g bespoke-synchrobespoke-synchro-mediator --port 9999
License
Sponsoship
Sponsored by nearForm