Skip to content

Commit

Permalink
(fix) update example
Browse files Browse the repository at this point in the history
  • Loading branch information
adwpc committed Nov 23, 2021
1 parent b59d3cc commit f68cdde
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 100 deletions.
2 changes: 1 addition & 1 deletion examples/ion-echo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
</style>

<title>Pion ion-sfu | Echotest</title>
<title>Pion ion | Echotest</title>
</head>

<body>
Expand Down
12 changes: 7 additions & 5 deletions examples/ion-echo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let localDataChannel;
let url = 'http://localhost:5551';
let sid = 'ion';
let uid = "local-user";

let connector;
let room;
const join = async () => {
console.log("[join]: sid="+sid+" uid=", uid)
Expand All @@ -33,7 +33,6 @@ const join = async () => {
console.log('[onclose]: service = ' + service.name);
};


room = new Ion.Room(connector);

room.onjoin = function (result){
Expand Down Expand Up @@ -115,8 +114,8 @@ const sendMsg = () => {
}
const payload = new Map();
payload.set('msg', localData.value);
console.log("[sendMsg]: sid=", sid, "from=", 'sender', "to=", uid, "payload=", payload);
room.message(sid,'sender', uid, 'Map', payload);
console.log("[sendMsg]: sid=", sid, "from=", uid, "to=", "all", "payload=", payload);
room.message(sid, "sender", "all", 'Map', payload);
}


Expand Down Expand Up @@ -153,12 +152,15 @@ local.onclose = function (service, err) {

const localRTC = new Ion.RTC(local);
const remoteRTC = new Ion.RTC(remote);
let trackEvent;

localRTC.join(sid, uid);

remoteRTC.ontrackevent = function (ev) {
console.log("[ontrackevent]: \nuid = ", ev.uid, " \nstate = ", ev.state, ", \ntracks = ", JSON.stringify(ev.tracks));
event = ev;
if (!trackEvent) {
trackEvent = ev;
}
remoteData.innerHTML = remoteData.innerHTML + JSON.stringify(ev) + '\n';
};

Expand Down
22 changes: 15 additions & 7 deletions examples/ion-pubsub/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ <h3>Pion</h3>
<div class="container pt-4">
<div class="row" id="start-btns">
<div class="col-12">
<button type="button" class="btn btn-primary" onclick="start(false)">
publish
</button>
<button type="button" class="btn btn-primary" onclick="start(true)">
publish(simulcast)
</button>
<div class="btn-group" role="group" aria-label="...">
<button id="join-btn" type="button" class="btn btn-primary" onclick="join()">
join
</button>
<button id="publish-btn" type="button" class="btn btn-primary" onclick="start(false)" disabled=true>
publish
</button>
<button id="publish-simulcast-btn" type="button" class="btn btn-primary" onclick="start(true)" disabled=true>
publish(simulcast)
</button>
<button id="leave-btn" type="button" class="btn btn-primary" onclick="leave()" disabled=true>
leave
</button>
</div>
</div>
</div>
<div class="row" >
Expand Down Expand Up @@ -136,7 +144,7 @@ <h3>Pion</h3>
</div>
</div>
<div class="row">
<div class="col-12 pt-4">DataChannel</div>
<div class="col-12 pt-4">Message</div>
</div>
<div class="row">
<div class="col-6 pt-2">
Expand Down
Loading

0 comments on commit f68cdde

Please sign in to comment.