Skip to content

Commit 95b3bd2

Browse files
committed
Address comments
1 parent c0a9f18 commit 95b3bd2

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

demo/web/javascript/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ <h2>2. Topic subscription — <code>/web_demo_chatter</code></h2>
200200
<button id="subBtn">subscribe</button>
201201
<button id="unsubBtn" disabled>unsubscribe</button>
202202
</div>
203-
<div class="log" id="tickLog"></div>
203+
<div class="log" id="subLog"></div>
204204
</div>
205205
<pre
206206
class="code"
@@ -405,14 +405,14 @@ <h2>
405405
};
406406

407407
let ros;
408-
let tickSub;
408+
let chatterSub;
409409

410410
async function teardown() {
411-
if (tickSub) {
411+
if (chatterSub) {
412412
try {
413-
await tickSub.close();
413+
await chatterSub.close();
414414
} catch (_) {}
415-
tickSub = null;
415+
chatterSub = null;
416416
document.getElementById('subBtn').disabled = false;
417417
document.getElementById('unsubBtn').disabled = true;
418418
}
@@ -470,23 +470,23 @@ <h2>
470470
subBtn.onclick = async () => {
471471
if (!ros) return;
472472
try {
473-
tickSub = await ros.subscribe('/web_demo_chatter', (msg) =>
474-
log('tickLog', msg.data)
473+
chatterSub = await ros.subscribe('/web_demo_chatter', (msg) =>
474+
log('subLog', msg.data)
475475
);
476476
subBtn.disabled = true;
477477
unsubBtn.disabled = false;
478-
log('tickLog', `subscribed (subId=${tickSub.subId})`, 'ok');
478+
log('subLog', `subscribed (subId=${chatterSub.subId})`, 'ok');
479479
} catch (e) {
480-
log('tickLog', `error: ${e.message} (${e.code})`, 'err');
480+
log('subLog', `error: ${e.message} (${e.code})`, 'err');
481481
}
482482
};
483483
unsubBtn.onclick = async () => {
484-
if (!tickSub) return;
485-
await tickSub.close();
486-
tickSub = null;
484+
if (!chatterSub) return;
485+
await chatterSub.close();
486+
chatterSub = null;
487487
unsubBtn.disabled = true;
488488
subBtn.disabled = false;
489-
log('tickLog', 'unsubscribed', 'ok');
489+
log('subLog', 'unsubscribed', 'ok');
490490
};
491491

492492
document.getElementById('pubBtn').onclick = async () => {

demo/web/javascript/web.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
"path": "/capability",
55
"node": "rclnodejs_web_demo",
66
"http": {
7-
"$comment": "HTTP transport for `call` and `publish`. curl-able, AI-agent friendly. Subscribe still uses WebSocket.",
8-
"port": 9001
7+
"$comment": "HTTP transport for `call` and `publish` (curl-able, AI-agent friendly). `sse` also exposes `subscribe` over Server-Sent Events; `cors: \"*\"` allows any origin so a cross-origin browser EventSource can connect. Matches the bundled runtime.mjs.",
8+
"port": 9001,
9+
"sse": true,
10+
"cors": "*"
911
},
1012
"expose": {
1113
"call": {

0 commit comments

Comments
 (0)