-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
94 changed files
with
5,117 additions
and
3,965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
}, | ||
"author": "", | ||
"license": "ISC" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="icon" type="image/svg+xml" href="favicon.svg" /> | ||
<title>SuperViz SDK</title> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="icon" type="image/svg+xml" href="favicon.svg" /> | ||
<title>SuperViz SDK</title> | ||
|
||
<!-- SuperViz SDK --> | ||
<script type="module" src="https://unpkg.com/@superviz/sdk@6.2.0-beta.1"></script> | ||
<!-- SuperViz SDK --> | ||
<script type="module" src="https://unpkg.com/@superviz/sdk@6.2.0-beta.1"></script> | ||
|
||
<!-- Main script, after SDK --> | ||
<script type="module" src="/scripts/main.js"></script> | ||
<link rel="stylesheet" href="/styles/main.css" /> | ||
</head> | ||
<body> | ||
<section> | ||
<div class="events-info"> | ||
<div class="container"> | ||
<h2>Subscription Manager</h2> | ||
<button id="subscribe">Subscribe to events</button> | ||
</div> | ||
<!-- Main script, after SDK --> | ||
<script type="module" src="/scripts/main.js"></script> | ||
<link rel="stylesheet" href="/styles/main.css" /> | ||
</head> | ||
<body> | ||
<section> | ||
<div class="events-info"> | ||
<div class="container"> | ||
<h2>Subscription Manager</h2> | ||
<button id="subscribe">Subscribe to events</button> | ||
</div> | ||
|
||
<div class="container" id="subscribedTo"> | ||
<h2>Not subscribed to any event</h2> | ||
</div> | ||
</div> | ||
<div class="container" id="subscribedTo"> | ||
<h2>Not subscribed to any event</h2> | ||
</div> | ||
</div> | ||
|
||
<hr /> | ||
<hr /> | ||
|
||
<div class="container"> | ||
<h2>Publising events</h2> | ||
<div class="subscribe-options"> | ||
<select id="eventName" disabled> | ||
<option value="one">one</option> | ||
<option value="two">two</option> | ||
<option value="three">three</option> | ||
</select> | ||
<input placeholder="Event message" id="eventMessage" /> | ||
<button id="publishButton">Publish</button> | ||
</div> | ||
</div> | ||
<div class="container"> | ||
<h2>Publising events</h2> | ||
<div class="subscribe-options"> | ||
<select id="eventName" disabled> | ||
<option value="one">one</option> | ||
<option value="two">two</option> | ||
<option value="three">three</option> | ||
</select> | ||
<input placeholder="Event message" id="eventMessage" /> | ||
<button id="publishButton">Publish</button> | ||
</div> | ||
</div> | ||
|
||
<div class="last-message container" id="lastElement"></div> | ||
</section> | ||
</body> | ||
<div class="last-message container" id="lastElement"></div> | ||
</section> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,81 @@ | ||
import { DEVELOPER_KEY } from "../env.js"; | ||
import { sampleInfo } from "../projectInfo.js"; | ||
import { DEVELOPER_KEY } from '../env.js' | ||
import { sampleInfo } from '../projectInfo.js' | ||
|
||
let room; | ||
let realtime; | ||
let channel; | ||
let room | ||
let realtime | ||
let channel | ||
|
||
const participant = Math.floor(Math.random() * 100); | ||
const groupId = sampleInfo.id; | ||
const groupName = sampleInfo.name; | ||
const participant = Math.floor(Math.random() * 100) | ||
const groupId = sampleInfo.id | ||
const groupName = sampleInfo.name | ||
|
||
document.getElementById("subscribe").addEventListener("click", subscribeToEvents); | ||
document.getElementById("publishButton").addEventListener("click", publishEvent); | ||
document.getElementById('subscribe').addEventListener('click', subscribeToEvents) | ||
document.getElementById('publishButton').addEventListener('click', publishEvent) | ||
|
||
function setLastPublishedMessage(message) { | ||
document.getElementById("lastElement").innerHTML = ` | ||
document.getElementById('lastElement').innerHTML = ` | ||
<p><strong>Last message:</strong> <span>${message.data?.toString()}</span></p> | ||
<p><strong>Published via:</strong> <span>${message.name}</span></p> | ||
<p><strong>Published by:</strong> <span>${message.participantId}</span></p> | ||
`; | ||
` | ||
} | ||
|
||
function callbackFunctionForWhenTheEventIsDispatched(message) { | ||
if (message.participantId === participant.toString()) return; | ||
if (message.participantId === participant.toString()) return | ||
|
||
setLastPublishedMessage(message); | ||
setLastPublishedMessage(message) | ||
} | ||
|
||
function subscribeToEvents() { | ||
channel.subscribe("one", callbackFunctionForWhenTheEventIsDispatched); | ||
channel.subscribe("two", callbackFunctionForWhenTheEventIsDispatched); | ||
channel.subscribe("three", callbackFunctionForWhenTheEventIsDispatched); | ||
channel.subscribe('one', callbackFunctionForWhenTheEventIsDispatched) | ||
channel.subscribe('two', callbackFunctionForWhenTheEventIsDispatched) | ||
channel.subscribe('three', callbackFunctionForWhenTheEventIsDispatched) | ||
|
||
document.getElementById("subscribedTo").innerHTML = `<h2>Subscribed to:</h2> | ||
document.getElementById('subscribedTo').innerHTML = `<h2>Subscribed to:</h2> | ||
<code>one</code> | ||
<code>two</code> | ||
<code>three</code>`; | ||
<code>three</code>` | ||
|
||
document.getElementById("eventName").disabled = false; | ||
document.getElementById('eventName').disabled = false | ||
} | ||
|
||
function publishEvent() { | ||
const eventDropdown = document.getElementById("eventName"); | ||
const messageInput = document.getElementById("eventMessage"); | ||
const eventDropdown = document.getElementById('eventName') | ||
const messageInput = document.getElementById('eventMessage') | ||
|
||
const eventName = eventDropdown.value; | ||
const messageToPublish = messageInput.value; | ||
const eventName = eventDropdown.value | ||
const messageToPublish = messageInput.value | ||
|
||
if (!eventName || !messageToPublish) return; | ||
if (!eventName || !messageToPublish) return | ||
|
||
channel.publish(eventName, messageToPublish); | ||
channel.publish(eventName, messageToPublish) | ||
} | ||
|
||
async function initializeSuperVizRoom() { | ||
room = await window.SuperVizRoom.init(DEVELOPER_KEY, { | ||
roomId: groupId, | ||
group: { | ||
id: groupId, | ||
name: groupName, | ||
}, | ||
participant: { | ||
id: participant.toString(), | ||
name: "John " + participant, | ||
}, | ||
}); | ||
|
||
realtime = new window.SuperVizRoom.Realtime(); | ||
|
||
realtime.subscribe("realtime-component.state-changed", (state) => { | ||
if (state === "STARTED") { | ||
channel = realtime.connect("your_channel_name"); | ||
console.log("Realtime component started", channel); | ||
} | ||
}); | ||
|
||
room.addComponent(realtime); | ||
|
||
return room; | ||
room = await window.SuperVizRoom.init(DEVELOPER_KEY, { | ||
roomId: groupId, | ||
group: { | ||
id: groupId, | ||
name: groupName, | ||
}, | ||
participant: { | ||
id: participant.toString(), | ||
name: 'John ' + participant, | ||
}, | ||
}) | ||
|
||
realtime = new window.SuperVizRoom.Realtime() | ||
|
||
realtime.subscribe('realtime-component.state-changed', (state) => { | ||
if (state === 'STARTED') { | ||
channel = realtime.connect('your_channel_name') | ||
console.log('Realtime component started', channel) | ||
} | ||
}) | ||
|
||
room.addComponent(realtime) | ||
|
||
return room | ||
} | ||
|
||
initializeSuperVizRoom(); | ||
initializeSuperVizRoom() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.