The Player View is part of a peer-to-peer system to allow players to connect to a DM's initiative tracker. Players should use the Initiative Tracker Player View page to connect to the DM's instance. As a DM, the usage is as follows:
Start the server.
Copy your link/token and share it with your players.
Wait for them to connect!
${$btnStartServer}${$btnGetLink}${$btnGetToken}
Please note that this system is highly experimental. Your experience may vary.
";
$wrpConnected.html(stack);
};
if (this._p2pMetaV1.serverPeer) this._p2pMetaV1.serverPeer.onTemp("connection", showConnected);
showConnected();
}
// nop on receiving a message; we want to send only
// TODO expand this, to allow e.g. players to set statuses or assign damage/healing (at DM approval?)
_playerWindowV0_DM_MESSAGE_RECEIVER = function () {};
_playerWindowV0_DM_ERROR_HANDLER = function (err) {
if (!this.isClosed) {
// TODO: this could be better at handling `err.error == "RTCError: User-Initiated Abort, reason=Close called"`
JqueryUtil.doToast({
content: `Server error:\n${err ? (err.message || err.error || err) : "(Unknown error)"}`,
type: "danger",
});
}
};
async _playerWindowV0_pGetServerTokens ({rowMetas}) {
const targetRows = rowMetas.filter(it => !it.isDeleted).filter(it => !it.isActive);
if (targetRows.every(it => it.isActive)) {
return JqueryUtil.doToast({
content: "No rows require Server Token generation!",
type: "warning",
});
}
let anyInvalidNames = false;
targetRows.forEach(row => {
row.$iptName.removeClass("error-background");
if (!row.$iptName.val().trim()) {
anyInvalidNames = true;
row.$iptName.addClass("error-background");
}
});
if (anyInvalidNames) return;
const names = targetRows.map(row => {
row.isActive = true;
row.$iptName.attr("disabled", true);
row.$btnGenServerToken.attr("disabled", true);
return row.$iptName.val();
});
if (this._p2pMetaV0.serverInfo) {
await this._p2pMetaV0.serverInfo;
const serverInfo = await PeerUtilV0.pInitialiseServersAddToExisting(
names,
this._p2pMetaV0.serverInfo,
this._playerWindowV0_DM_MESSAGE_RECEIVER,
this._playerWindowV0_DM_ERROR_HANDLER,
);
return targetRows.map((row, i) => {
row.name = serverInfo[i].name;
row.serverInfo = serverInfo[i];
row.$iptTokenServer.val(serverInfo[i].textifiedSdp).attr("disabled", false);
serverInfo[i].rowMeta = row;
row.$iptTokenClient.attr("disabled", false);
row.$btnAcceptClientToken.attr("disabled", false);
return serverInfo[i].textifiedSdp;
});
} else {
this._p2pMetaV0.serverInfo = (async () => {
this._p2pMetaV0.serverInfo = await PeerUtilV0.pInitialiseServers(names, this._playerWindowV0_DM_MESSAGE_RECEIVER, this._playerWindowV0_DM_ERROR_HANDLER);
targetRows.forEach((row, i) => {
row.name = this._p2pMetaV0.serverInfo[i].name;
row.serverInfo = this._p2pMetaV0.serverInfo[i];
row.$iptTokenServer.val(this._p2pMetaV0.serverInfo[i].textifiedSdp).attr("disabled", false);
this._p2pMetaV0.serverInfo[i].rowMeta = row;
row.$iptTokenClient.attr("disabled", false);
row.$btnAcceptClientToken.attr("disabled", false);
});
})();
await this._p2pMetaV0.serverInfo;
return targetRows.map(row => row.serverInfo.textifiedSdp);
}
}
handleClick_playerWindowV0 ({doUpdateExternalStates}) {
const {$modalInner} = UiUtil.getShowModal({
title: "Configure Player View",
isUncappedHeight: true,
isHeight100: true,
cbClose: () => {
if (this._p2pMetaV0.rows.length) this._p2pMetaV0.rows.forEach(row => row.$row.detach());
},
});
const $wrpHelp = UiUtil.$getAddModalRow($modalInner, "div");
const $btnAltGenAll = $(``).click(() => $btnGenServerTokens.click());
const $btnAltCopyAll = $(``).click(() => $btnCopyServers.click());
$$`
The Player View is part of a peer-to-peer (i.e., serverless) system to allow players to connect to a DM's initiative tracker. Players should use the Initiative Tracker Player View page to connect to the DM's instance. As a DM, the usage is as follows:
Add the required number of players, and input (preferably unique) player names.
Click "${$btnAltGenAll}," which will generate a "server token" per player. You can click "${$btnAltCopyAll}" to copy them all as a single block of text, or click on the "Server Token" values to copy them individually. Distribute these tokens to your players (via a messaging service of your choice; we recommend Discord). Each player should paste their token into the Initiative Tracker Player View, following the instructions provided therein.
Get a resulting "client token" from each player via a messaging service of your choice. Then, either:
Click the "Accept Multiple Clients" button, and paste in text containing multiple client tokens. This will try to find tokens in any text, ignoring everything else. Pasting a chatroom log (containing, for example, usernames and timestamps mixed with tokens) is the expected usage.
Paste each token into the appropriate "Client Token" field and "Accept Client" on each. A token can be identified by the slugified player name in the first few characters.
Once a player's client has been "accepted," it will receive updates from the DM's tracker. Please note that this system is highly experimental. Your experience may vary.