-
Notifications
You must be signed in to change notification settings - Fork 5
Peer 2 Peer
Two or more browsers with JS-Eden can be connected together in a few different modes using peer-2-peer networking. This page documents this experimental technology.
Extra URL parameters are required to set up P2P at present. There are three such parameters:
-
id- Set an explicit name for your peer node. Essentially this creates a "server". If not specified then you must specifymasterotherwise p2p is disabled. The defaultidis random. -
master- Specifies a peer id to connect to. -
roles- A comma list of roles played by this browser page. Roles can be used to control which browser should execute awhenagent since often it makes sense for it to only be done in one place.
The general connection procedure involves create a browser page with an id as a server and then connecting one or more other pages with a master parameter.
When a client connects using master, the master browser gets a notification which the user can then use to select the kind of interaction mode desired. The options are:
- Watch - To passively observe the connecting client but without any ability to affect changes.
- Broadcast - To send your construal and all interactions with it to each connected client. However, each client cannot affect the master.
- Collaborate - A two way connection where changes in either browser are sent to the other(s).
- Mash - Not yet available but would allow different construals to interact with otherwise minimal sync.
All state changing interactions with a construal become subject to a network synchronisation, or can be. Whether or not a state change is sent to all connected browsers depends upon the agent that caused that change. Each agent can be defined as local only or not, this is true of when or of JavaScript and input device agents.
local when (my_image_x < 400) {
wait 200;
my_image_x += 20;
}
The above declares that this when will only influence local state, its state changes are not to be sent. Without the local keyword (the default case) all changes made by a when are sent.
Other agents are controlled via observables:
-
jseden_p2p_captureinput- If true then all HCI inputs and local javascript agency is also sent. Default isfalse.
Each when statement can have a specified role or roles to indicate that it should only be executed if this browser instance has one of the specified roles, otherwise the when is ignored and left to some other browser to deal with.
when role x (my_image_x < 400) {
}
or
when role x,y,z (my_image_x < 400) {
}