Skip to content

Commit f68cdde

Browse files
committed
(fix) update example
1 parent b59d3cc commit f68cdde

4 files changed

Lines changed: 217 additions & 100 deletions

File tree

examples/ion-echo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
}
4545
</style>
4646

47-
<title>Pion ion-sfu | Echotest</title>
47+
<title>Pion ion | Echotest</title>
4848
</head>
4949

5050
<body>

examples/ion-echo/main.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let localDataChannel;
1919
let url = 'http://localhost:5551';
2020
let sid = 'ion';
2121
let uid = "local-user";
22-
22+
let connector;
2323
let room;
2424
const join = async () => {
2525
console.log("[join]: sid="+sid+" uid=", uid)
@@ -33,7 +33,6 @@ const join = async () => {
3333
console.log('[onclose]: service = ' + service.name);
3434
};
3535

36-
3736
room = new Ion.Room(connector);
3837

3938
room.onjoin = function (result){
@@ -115,8 +114,8 @@ const sendMsg = () => {
115114
}
116115
const payload = new Map();
117116
payload.set('msg', localData.value);
118-
console.log("[sendMsg]: sid=", sid, "from=", 'sender', "to=", uid, "payload=", payload);
119-
room.message(sid,'sender', uid, 'Map', payload);
117+
console.log("[sendMsg]: sid=", sid, "from=", uid, "to=", "all", "payload=", payload);
118+
room.message(sid, "sender", "all", 'Map', payload);
120119
}
121120

122121

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

154153
const localRTC = new Ion.RTC(local);
155154
const remoteRTC = new Ion.RTC(remote);
155+
let trackEvent;
156156

157157
localRTC.join(sid, uid);
158158

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

examples/ion-pubsub/index.html

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,20 @@ <h3>Pion</h3>
3434
<div class="container pt-4">
3535
<div class="row" id="start-btns">
3636
<div class="col-12">
37-
<button type="button" class="btn btn-primary" onclick="start(false)">
38-
publish
39-
</button>
40-
<button type="button" class="btn btn-primary" onclick="start(true)">
41-
publish(simulcast)
42-
</button>
37+
<div class="btn-group" role="group" aria-label="...">
38+
<button id="join-btn" type="button" class="btn btn-primary" onclick="join()">
39+
join
40+
</button>
41+
<button id="publish-btn" type="button" class="btn btn-primary" onclick="start(false)" disabled=true>
42+
publish
43+
</button>
44+
<button id="publish-simulcast-btn" type="button" class="btn btn-primary" onclick="start(true)" disabled=true>
45+
publish(simulcast)
46+
</button>
47+
<button id="leave-btn" type="button" class="btn btn-primary" onclick="leave()" disabled=true>
48+
leave
49+
</button>
50+
</div>
4351
</div>
4452
</div>
4553
<div class="row" >
@@ -136,7 +144,7 @@ <h3>Pion</h3>
136144
</div>
137145
</div>
138146
<div class="row">
139-
<div class="col-12 pt-4">DataChannel</div>
147+
<div class="col-12 pt-4">Message</div>
140148
</div>
141149
<div class="row">
142150
<div class="col-6 pt-2">

0 commit comments

Comments
 (0)