Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit c9a7d2b

Browse files
committed
Rename channelOptions to peerOptions. Describe it thoroughly.
1 parent 734f8f4 commit c9a7d2b

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/index.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,24 @@ import type { Multiaddr } from '@multiformats/multiaddr'
2222

2323
const log = logger('libp2p:webrtcdirect')
2424

25+
interface SimplePeerOptions {
26+
channelConfig?: Object,
27+
channelName?: string,
28+
config?: Object,
29+
offerOptions?: Object,
30+
answerOptions?: Object,
31+
sdpTransform?: <T>(sdp: T) => T,
32+
stream?: boolean,
33+
streams?: any[],
34+
objectMode?: boolean
35+
}
36+
2537
export interface WebRTCDirectListenerOptions extends ListenerOptions{
26-
channelOptions?: Object
38+
peerOptions?: SimplePeerOptions
2739
}
2840

2941
export interface WebRTCDirectDialOptions extends AbortOptions{
30-
channelOptions?: Object
42+
peerOptions?: SimplePeerOptions
3143
}
3244

3345
export class WebRTCDirect implements Transport<AbortOptions, ListenerOptions> {
@@ -57,11 +69,11 @@ export class WebRTCDirect implements Transport<AbortOptions, ListenerOptions> {
5769
throw new AbortError()
5870
}
5971

60-
const channelOptions = {
72+
const peerOptions = {
6173
initiator: true,
6274
trickle: false,
6375
wrtc: isNode ? wrtc : undefined,
64-
...options?.channelOptions
76+
...options?.peerOptions
6577
}
6678

6779
return new Promise((resolve, reject) => {
@@ -71,7 +83,7 @@ export class WebRTCDirect implements Transport<AbortOptions, ListenerOptions> {
7183
const cOpts = ma.toOptions()
7284
log('Dialing %s:%s', cOpts.host, cOpts.port)
7385

74-
const channel = new SimplePeer(channelOptions)
86+
const channel = new SimplePeer(peerOptions)
7587

7688
const onError = (err: Error) => {
7789
if (!connected) {

src/listener.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface WebRTCDirectListener extends Listener {
3030

3131
export function createListener (upgrader: Upgrader, options?: WebRTCDirectListenerOptions) {
3232
const handler = options?.handler
33-
const channelOptions = options?.channelOptions
33+
const peerOptions = options?.peerOptions
3434
const server = http.createServer()
3535

3636
let maSelf: Multiaddr
@@ -54,7 +54,7 @@ export function createListener (upgrader: Upgrader, options?: WebRTCDirectListen
5454
const channel = new SimplePeer({
5555
trickle: false,
5656
wrtc: isNode ? wrtc : undefined,
57-
...channelOptions
57+
...peerOptions
5858
})
5959

6060
const maConn = toMultiaddrConnection(channel, {

0 commit comments

Comments
 (0)