open-audiovisual
Search GitHub

oav-p5 reference · The OAVp5 object (advanced)

OAVp5.link.info#

variableoav-p5
OAVp5.link.info

The state of the link: its room, state (connecting, open, closed), how many other pages are there, and the trip time. null when no room is set.

Read it in draw() for a status line, or look at the 🔗 on the 🎹, which turns green when another page is there, yellow while connecting or alone, and red when the relay is gone. The 🩺 check-up prints the same facts. A new object is made on every read.

Type
Object | null

null without a link room. With one: { room, state, peers, rtt, trip, late, sent, received, … }. state is 'connecting', 'open' or 'closed' (the relay is gone and it retries). peers is how many other pages were heard in the last 6 seconds. rtt is the shortest round trip to the relay in the last 30 seconds and trip the one-way trip estimated from it, both in milliseconds. late counts notes that arrived after the moment they should have sounded and were played at once. sent and received count messages. The object also has diff, lead, msgs, dupes and id, which explain the clock alignment (packages/relay/link.js).

Examples

js
window.OAV_P5 = { link: 'my-room' };

function setup() {
  createCanvas(400, 300);
}

function draw() {
  background(20);
  fill(255);
  const i = OAVp5.link.info;
  text('room: ' + i.room + ',  state: ' + i.state, 20, 30);
  text('other pages: ' + i.peers + ',  one-way trip: ' + (i.trip == null ? '-' : i.trip + ' ms'), 20, 60);
}
static Open the same address in two tabs: both say "open" and one other page, and show the trip time.
jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
}

function draw() {
  background(20);
  fill(255);
  text('link.info: ' + JSON.stringify(OAVp5.link.info), 20, 30);   // null: no room
}
Without a link room it prints null.

To be confirmed

The values between two real pages were not observed here: the headless check cannot reach a relay. The fields and their meanings are from the code (packages/relay/link.js) and the project's README.

Related

  • OAVp5.link What the link to other oav-p5 pages in the same room is doing: only OAVp5.link.info, and null unless a room is set.
  • link Joins a room: oav-p5 pages with the same room hear what each other's programs play, over the relay. A room name, or empty for none.
  • linkdelay Extra milliseconds of buffer on the notes a linked page receives, to smooth out an uneven network: 0 to 2000.
  • relay The address of the relay that phones and link rooms talk through: a WebSocket URL.

p5/oav-p5.js, line 884

↑ Back to top · All names