Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Jan 1, 2024
1 parent a696db4 commit 7bbb1b7
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/webrtc/src/dataChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/webrtc/src/transport/sctp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion packages/webrtc/tests/datachannel/send.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions packages/webrtc/tests/integrate/datachannel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions packages/webrtc/tests/integrate/peerConnection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -189,7 +189,7 @@ describe("initial config", () => {
};

callee.onDataChannel.subscribe((channel) => {
channel.message.once(() => {
channel.onMessage.once(() => {
caller.close();
callee.close();
done();
Expand Down Expand Up @@ -222,7 +222,7 @@ describe("initial config", () => {
};

callee.onDataChannel.subscribe((channel) => {
channel.message.once(() => {
channel.onMessage.once(() => {
caller.close();
callee.close();
done();
Expand Down Expand Up @@ -255,7 +255,7 @@ describe("initial config", () => {
};

callee.onDataChannel.subscribe((channel) => {
channel.message.once(() => {
channel.onMessage.once(() => {
caller.close();
callee.close();
done();
Expand Down
4 changes: 2 additions & 2 deletions packages/webrtc/tests/integrate/trickle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/webrtc/tests/transport/sctp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -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"));
});
Expand Down
2 changes: 1 addition & 1 deletion packages/webrtc/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7bbb1b7

Please sign in to comment.