summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client-web/source/user/remote.ts18
-rw-r--r--common/packets.d.ts7
2 files changed, 11 insertions, 14 deletions
diff --git a/client-web/source/user/remote.ts b/client-web/source/user/remote.ts
index bee3042..acd52ac 100644
--- a/client-web/source/user/remote.ts
+++ b/client-web/source/user/remote.ts
@@ -110,28 +110,26 @@ export class RemoteUser extends User {
this.negotiation_busy = true
const offer_description = await this.peer.createOffer()
await this.peer.setLocalDescription(offer_description)
- const offer = { type: offer_description.type, sdp: offer_description.sdp }
- log("webrtc", `sent offer: ${this.display_name}`, { offer })
- this.room.signaling.send_relay({ offer }, this.id)
+ log("webrtc", `sent offer: ${this.display_name}`, { offer: offer_description.sdp })
+ this.room.signaling.send_relay({ offer: offer_description.sdp }, this.id)
}
- async on_offer(offer: RTCSessionDescriptionInit) {
+ async on_offer(offer: string) {
this.negotiation_busy = true
log("webrtc", `got offer: ${this.display_name}`, { offer })
- const offer_description = new RTCSessionDescription(offer)
+ const offer_description = new RTCSessionDescription({ sdp: offer, type: "offer" })
await this.peer.setRemoteDescription(offer_description)
this.answer()
}
async answer() {
const answer_description = await this.peer.createAnswer()
await this.peer.setLocalDescription(answer_description)
- const answer = { type: answer_description.type, sdp: answer_description.sdp }
- log("webrtc", `sent answer: ${this.display_name}`, { answer })
- this.room.signaling.send_relay({ answer }, this.id)
+ log("webrtc", `sent answer: ${this.display_name}`, { answer: answer_description.sdp })
+ this.room.signaling.send_relay({ answer: answer_description.sdp }, this.id)
this.negotiation_busy = false
}
- async on_answer(answer: RTCSessionDescriptionInit) {
+ async on_answer(answer: string) {
log("webrtc", `got answer: ${this.display_name}`, { answer })
- const answer_description = new RTCSessionDescription(answer)
+ const answer_description = new RTCSessionDescription({ sdp: answer, type: "answer" })
await this.peer.setRemoteDescription(answer_description)
this.negotiation_busy = false
}
diff --git a/common/packets.d.ts b/common/packets.d.ts
index c5e9637..02108a3 100644
--- a/common/packets.d.ts
+++ b/common/packets.d.ts
@@ -1,7 +1,6 @@
// copy pasted from dom.lib.d.ts because it can not be referenced in the server.
-type F_RTCSdpType = "answer" | "offer" | "pranswer" | "rollback";
-interface F_RTCSessionDescriptionInit { sdp?: string; type: F_RTCSdpType; }
+type Sdp = string
interface F_RTCIceCandidateInit { candidate?: string; sdpMLineIndex?: number | null; sdpMid?: string | null; usernameFragment?: string | null; }
export interface /* enum */ ClientboundPacket {
@@ -28,8 +27,8 @@ export interface /* enum */ RelayMessage {
provide?: ProvideInfo
request?: { id: number }
- offer?: F_RTCSessionDescriptionInit,
- answer?: F_RTCSessionDescriptionInit,
+ offer?: Sdp,
+ answer?: Sdp,
ice_candidate?: F_RTCIceCandidateInit,
}
export interface ChatMessage { text?: string, image?: string }