From 7bbb1b77e9bbf371a866cc79bc403ece6795c07a Mon Sep 17 00:00:00 2001 From: shinyoshiaki Date: Mon, 1 Jan 2024 14:39:21 +0900 Subject: [PATCH] rename --- packages/webrtc/src/dataChannel.ts | 2 +- packages/webrtc/src/transport/sctp.ts | 2 +- packages/webrtc/tests/datachannel/send.test.ts | 2 +- packages/webrtc/tests/integrate/datachannel.test.ts | 6 +++--- packages/webrtc/tests/integrate/peerConnection.test.ts | 10 +++++----- packages/webrtc/tests/integrate/trickle.test.ts | 4 ++-- packages/webrtc/tests/transport/sctp.test.ts | 4 ++-- packages/webrtc/tests/utils.ts | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/webrtc/src/dataChannel.ts b/packages/webrtc/src/dataChannel.ts index 879782c8f..e7a8a43be 100644 --- a/packages/webrtc/src/dataChannel.ts +++ b/packages/webrtc/src/dataChannel.ts @@ -9,7 +9,7 @@ const log = debug("werift:packages/webrtc/src/dataChannel.ts"); export class RTCDataChannel extends EventTarget { readonly stateChanged = new Event<[DCState]>(); - readonly message = new Event<[string | Buffer]>(); + readonly onMessage = new Event<[string | Buffer]>(); // todo impl readonly error = new Event<[Error]>(); readonly bufferedAmountLow = new Event(); diff --git a/packages/webrtc/src/transport/sctp.ts b/packages/webrtc/src/transport/sctp.ts index 3fc67162c..e262f7a32 100644 --- a/packages/webrtc/src/transport/sctp.ts +++ b/packages/webrtc/src/transport/sctp.ts @@ -194,7 +194,7 @@ export class RTCSctpTransport { } })(); - channel.message.execute(msg); + channel.onMessage.execute(msg); channel.emit("message", { data: msg }); if (channel.onmessage) { channel.onmessage({ data: msg }); diff --git a/packages/webrtc/tests/datachannel/send.test.ts b/packages/webrtc/tests/datachannel/send.test.ts index 81cbc7dd7..cbde685a3 100644 --- a/packages/webrtc/tests/datachannel/send.test.ts +++ b/packages/webrtc/tests/datachannel/send.test.ts @@ -53,7 +53,7 @@ describe.each([{}, { negotiated: true, id: 0 }])( }; createDataChannelPair(options).then(([channel1, channel2]) => { - channel2.message.subscribe(onMessage); + channel2.onMessage.subscribe(onMessage); channel1.send(helloBuffer); channel1.send(unicodeString); diff --git a/packages/webrtc/tests/integrate/datachannel.test.ts b/packages/webrtc/tests/integrate/datachannel.test.ts index ff47e25ac..91e184568 100644 --- a/packages/webrtc/tests/integrate/datachannel.test.ts +++ b/packages/webrtc/tests/integrate/datachannel.test.ts @@ -10,9 +10,9 @@ describe("datachannel", () => { pc2.onDataChannel.subscribe((channel) => { Promise.all([ - channel.message.watch((v) => v === "1"), - channel.message.watch((v) => v === "2"), - channel.message.watch((v) => v === "3"), + channel.onMessage.watch((v) => v === "1"), + channel.onMessage.watch((v) => v === "2"), + channel.onMessage.watch((v) => v === "3"), ]).then(async () => { await pc1.close(); await pc2.close(); diff --git a/packages/webrtc/tests/integrate/peerConnection.test.ts b/packages/webrtc/tests/integrate/peerConnection.test.ts index 7c684f9a5..8fe0701b0 100644 --- a/packages/webrtc/tests/integrate/peerConnection.test.ts +++ b/packages/webrtc/tests/integrate/peerConnection.test.ts @@ -17,7 +17,7 @@ describe("peerConnection", () => { const pc2 = new RTCPeerConnection({}); pc2.onDataChannel.subscribe((channel) => { - channel.message.subscribe((data) => { + channel.onMessage.subscribe((data) => { expect(data.toString()).toBe("hello"); done(); }); @@ -94,7 +94,7 @@ describe("peerConnection", () => { const dc = pcOffer.createDataChannel("chat"); pcAnswer.onDataChannel.subscribe((channel) => { - channel.message.subscribe(async (data) => { + channel.onMessage.subscribe(async (data) => { expect(data.toString()).toBe("hello"); channel.close(); await Promise.all([ @@ -189,7 +189,7 @@ describe("initial config", () => { }; callee.onDataChannel.subscribe((channel) => { - channel.message.once(() => { + channel.onMessage.once(() => { caller.close(); callee.close(); done(); @@ -222,7 +222,7 @@ describe("initial config", () => { }; callee.onDataChannel.subscribe((channel) => { - channel.message.once(() => { + channel.onMessage.once(() => { caller.close(); callee.close(); done(); @@ -255,7 +255,7 @@ describe("initial config", () => { }; callee.onDataChannel.subscribe((channel) => { - channel.message.once(() => { + channel.onMessage.once(() => { caller.close(); callee.close(); done(); diff --git a/packages/webrtc/tests/integrate/trickle.test.ts b/packages/webrtc/tests/integrate/trickle.test.ts index 9a1db0faa..97aaf1991 100644 --- a/packages/webrtc/tests/integrate/trickle.test.ts +++ b/packages/webrtc/tests/integrate/trickle.test.ts @@ -14,7 +14,7 @@ describe("trickle", () => { iceServers: [{ urls: "stun:stun.l.google.com:19302" }], }); pcAnswer.onDataChannel.subscribe((dc) => { - dc.message.subscribe((data) => { + dc.onMessage.subscribe((data) => { expect(data.toString()).toBe("hello"); done(); }); @@ -53,7 +53,7 @@ describe("trickle", () => { iceServers: [{ urls: "stun:stun.l.google.com:19302" }], }); pcAnswer.onDataChannel.subscribe((dc) => { - dc.message.subscribe((data) => { + dc.onMessage.subscribe((data) => { expect(data.toString()).toBe("hello"); done(); }); diff --git a/packages/webrtc/tests/transport/sctp.test.ts b/packages/webrtc/tests/transport/sctp.test.ts index 81ae8bb2d..bfe8a23eb 100644 --- a/packages/webrtc/tests/transport/sctp.test.ts +++ b/packages/webrtc/tests/transport/sctp.test.ts @@ -42,7 +42,7 @@ describe("RTCSctpTransportTest", () => { const serverChannels = trackChannels(server); serverChannels.event.subscribe((channel) => { channel.send(Buffer.from("ping")); - channel.message.subscribe((data) => { + channel.onMessage.subscribe((data) => { expect(data.toString()).toBe("pong"); done(); }); @@ -52,7 +52,7 @@ describe("RTCSctpTransportTest", () => { client, new RTCDataChannelParameters({ label: "chat", id: 1 }), ); - channel.message.subscribe((data) => { + channel.onMessage.subscribe((data) => { expect(data.toString()).toBe("ping"); channel.send(Buffer.from("pong")); }); diff --git a/packages/webrtc/tests/utils.ts b/packages/webrtc/tests/utils.ts index 25cc5da86..fe3a899ec 100644 --- a/packages/webrtc/tests/utils.ts +++ b/packages/webrtc/tests/utils.ts @@ -116,7 +116,7 @@ export function awaitMessage(channel: RTCDataChannel) { r(e.data); }), ), - channel.message.asPromise(), + channel.onMessage.asPromise(), ]).then(([msg]) => resolve(msg)); channel.error.once(reject);