OAVp5.link.info#
variableoav-p5OAVp5.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
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);
}function setup() {
createCanvas(400, 300);
}
function draw() {
background(20);
fill(255);
text('link.info: ' + JSON.stringify(OAVp5.link.info), 20, 30); // null: no room
}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.linkWhat the link to other oav-p5 pages in the same room is doing: onlyOAVp5.link.info, andnullunless a room is set.linkJoins 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.linkdelayExtra milliseconds of buffer on the notes a linked page receives, to smooth out an uneven network: 0 to 2000.relayThe address of the relay that phones andlinkrooms talk through: a WebSocket URL.