Skip to content

Commit 0421c25

Browse files
committed
[docs] Demonstrate web-native SSE subscribe in READMEs
1 parent df5044f commit 0421c25

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ how much glue you want to write.
133133
); // reply.sum is typed as `${number}n`
134134
```
135135

136+
No SDK needed for subscribe — any browser streams a live ROS 2 topic via built-in `EventSource`:
137+
138+
```js
139+
const es = new EventSource('http://host:9000/capability/subscribe/chatter');
140+
es.onmessage = (e) => console.log(JSON.parse(e.data)); // live ROS 2 messages
141+
```
142+
136143
- **[`rosocket`](./rosocket/README.md)** — thin WebSocket gateway,
137144
zero browser dependencies (just built-in `WebSocket` + `JSON`).
138145
Best for quick prototypes and `roslibjs`-style apps.

scripts/npmjs-readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ Then `import * as rclnodejs from 'rclnodejs'` works the same as the JavaScript e
110110
); // reply.sum is typed as `${number}n`
111111
```
112112

113+
No SDK needed for subscribe — any browser streams a live ROS 2 topic via built-in `EventSource`:
114+
115+
```js
116+
const es = new EventSource('http://host:9000/capability/subscribe/chatter');
117+
es.onmessage = (e) => console.log(JSON.parse(e.data)); // live ROS 2 messages
118+
```
119+
113120
See the [Web SDK guide](https://github.com/RobotWebTools/rclnodejs/tree/develop/web).
114121

115122
- **`rosocket`** — thin WebSocket gateway, zero browser dependencies (just built-in `WebSocket` + `JSON`). Best for quick prototypes and `roslibjs`-style apps.

0 commit comments

Comments
 (0)