@elefunc/send 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/protocol.ts +6 -0
- package/src/core/session.ts +4 -4
package/package.json
CHANGED
package/src/core/protocol.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { RTCIceCandidateInit, RTCIceServer, RTCSessionDescriptionInit } from "werift"
|
|
2
2
|
|
|
3
3
|
export const SIGNAL_WS_URL = "wss://sig.efn.kr/ws"
|
|
4
|
+
export const SIGNAL_PULSE_URL = "https://sig.efn.kr/pulse?app=send"
|
|
5
|
+
export const signalSocketUrl = (room: string) => {
|
|
6
|
+
const url = new URL(SIGNAL_WS_URL)
|
|
7
|
+
url.search = new URLSearchParams({ i: room, app: "send" }).toString()
|
|
8
|
+
return url.toString()
|
|
9
|
+
}
|
|
4
10
|
export const BASE_ICE_SERVERS = [
|
|
5
11
|
{ urls: "stun:stun.cloudflare.com:3478" },
|
|
6
12
|
{ urls: "stun:stun.l.google.com:19302" },
|
package/src/core/session.ts
CHANGED
|
@@ -19,7 +19,9 @@ import {
|
|
|
19
19
|
fallbackName,
|
|
20
20
|
formatEta,
|
|
21
21
|
formatRate,
|
|
22
|
+
SIGNAL_PULSE_URL,
|
|
22
23
|
signalEpoch,
|
|
24
|
+
signalSocketUrl,
|
|
23
25
|
stamp,
|
|
24
26
|
turnStateLabel,
|
|
25
27
|
type CandidateSignal,
|
|
@@ -171,8 +173,6 @@ export interface SessionConfig {
|
|
|
171
173
|
const LOG_LIMIT = 200
|
|
172
174
|
const STATS_POLL_MS = 1000
|
|
173
175
|
const PROFILE_URL = "https://ip.rt.ht/"
|
|
174
|
-
const PULSE_URL = "https://sig.efn.kr/pulse"
|
|
175
|
-
|
|
176
176
|
export interface PeerConnectivitySnapshot {
|
|
177
177
|
rttMs: number
|
|
178
178
|
localCandidateType: string
|
|
@@ -953,7 +953,7 @@ export class SendSession {
|
|
|
953
953
|
if (this.stopped) return
|
|
954
954
|
if (this.reconnectTimer) clearTimeout(this.reconnectTimer)
|
|
955
955
|
const token = ++this.socketToken
|
|
956
|
-
const socket = new WebSocket(
|
|
956
|
+
const socket = new WebSocket(signalSocketUrl(this.room))
|
|
957
957
|
this.socket = socket
|
|
958
958
|
this.socketState = "connecting"
|
|
959
959
|
this.emit({ type: "socket", socketState: this.socketState })
|
|
@@ -1012,7 +1012,7 @@ export class SendSession {
|
|
|
1012
1012
|
this.pulse = { ...this.pulse, state: "checking", error: "" }
|
|
1013
1013
|
this.notify()
|
|
1014
1014
|
try {
|
|
1015
|
-
const response = await fetch(
|
|
1015
|
+
const response = await fetch(SIGNAL_PULSE_URL, { cache: "no-store", signal: timeoutSignal(3500, this.lifecycleAbortController?.signal) })
|
|
1016
1016
|
if (!response.ok) throw new Error(`pulse ${response.status}`)
|
|
1017
1017
|
if (this.stopped) return
|
|
1018
1018
|
this.pulse = { state: "open", at: Date.now(), ms: performance.now() - startedAt, error: "" }
|