forked from libp2p/js-libp2p-webrtc-star
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
54 lines (44 loc) · 1.06 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import type { Socket } from 'socket.io-client'
export interface OfferSignal {
type: 'offer'
sdp: string
}
export interface AnswerSignal {
type: 'answer'
sdp: string
}
export interface CandidateSignal {
type: 'candidate'
candidate: {
candidate: string
sdpMLineIndex?: number
sdpMid?: string
}
}
export interface RenegotiateSignal {
type: 'renegotiate'
}
export interface GoodbyeSignal {
type: 'goodbye'
}
export type Signal = OfferSignal | AnswerSignal | CandidateSignal | RenegotiateSignal | GoodbyeSignal
export interface HandshakeSignal {
srcMultiaddr: string
dstMultiaddr: string
intentId: string
signal: Signal
answer?: boolean
err?: string
}
interface SocketEvents {
'ss-handshake': (offer: HandshakeSignal) => void
'ss-join': (maStr: string) => void
'ss-leave': (maStr: string) => void
'ws-peer': (maStr: string) => void
'ws-handshake': (offer: HandshakeSignal) => void
'error': (err: Error) => void
'listening': () => void
'close': () => void
}
export interface WebRTCStarSocket extends Socket<SocketEvents> {
}