Skip to content

Commit d94b000

Browse files
authored
Revert rename of connection event (#1091)
1 parent ede2397 commit d94b000

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "roslib",
33
"homepage": "https://robotwebtools.github.io",
44
"description": "The standard ROS Javascript Library",
5-
"version": "2.0.0-alpha5",
5+
"version": "2.0.0-alpha6",
66
"license": "BSD-2-Clause",
77
"files": [
88
"dist"

src/core/Ros.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export interface TypeDefDict {
4242
* Manages connection to the rosbridge server and all interactions with ROS.
4343
*
4444
* Emits the following events:
45-
* * 'open' - Connected to the rosbridge server.
45+
* * 'connection' - Connected to the rosbridge server.
4646
* * 'close' - Disconnected to the rosbridge server.
4747
* * 'error' - There was an error with ROS.
4848
* * <topicName> - A message came from rosbridge with the given topic name.
4949
* * <serviceID> - A service response came from rosbridge with the given ID.
5050
*/
5151
export default class Ros extends EventEmitter<
5252
{
53-
open: [TransportEvent];
53+
connection: [TransportEvent];
5454
close: [TransportEvent];
5555
error: [TransportEvent];
5656
// Any dynamically-named event should correspond to a rosbridge protocol message
@@ -101,7 +101,7 @@ export default class Ros extends EventEmitter<
101101

102102
transport.on("open", (event: TransportEvent) => {
103103
this.#isConnected = true;
104-
this.emit("open", event);
104+
this.emit("connection", event);
105105
});
106106

107107
transport.on("close", (event: TransportEvent) => {
@@ -191,7 +191,7 @@ export default class Ros extends EventEmitter<
191191
if (this.isConnected()) {
192192
this.transport?.send(message);
193193
} else {
194-
this.once("open", () => {
194+
this.once("connection", () => {
195195
this.transport?.send(message);
196196
});
197197
}

test/ros.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ describe("Ros", function () {
247247
const rosOnceSpy = vi.spyOn(ros, "once");
248248
ros.callOnConnection({ op: "set_level", level: "info" });
249249

250-
expect(rosOnceSpy).toHaveBeenCalledWith("open", expect.any(Function));
250+
expect(rosOnceSpy).toHaveBeenCalledWith(
251+
"connection",
252+
expect.any(Function),
253+
);
251254
expect(mockTransport.send).not.toHaveBeenCalled();
252255

253256
// Once connected, the message is sent

test/setup/ros-backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function waitForRosConnection(ros: Ros, timeout = 5000) {
2727
reject(new Error("Timeout waiting for ROS connection"));
2828
}, timeout);
2929

30-
ros.on("open", () => {
30+
ros.on("connection", () => {
3131
clearTimeout(timeoutId);
3232
resolve();
3333
});

0 commit comments

Comments
 (0)