@@ -33,20 +33,20 @@ var (
33
33
)
34
34
35
35
// Client creates a new client connection.
36
- func Client (servers []webrtc.ICEServer , opts * ConnOpts ) (* Conn , error ) {
36
+ func Client (servers []webrtc.ICEServer , opts * ConnOptions ) (* Conn , error ) {
37
37
return newWithClientOrServer (servers , true , opts )
38
38
}
39
39
40
40
// Server creates a new server connection.
41
- func Server (servers []webrtc.ICEServer , opts * ConnOpts ) (* Conn , error ) {
41
+ func Server (servers []webrtc.ICEServer , opts * ConnOptions ) (* Conn , error ) {
42
42
return newWithClientOrServer (servers , false , opts )
43
43
}
44
44
45
45
// newWithClientOrServer constructs a new connection with the client option.
46
46
// nolint:revive
47
- func newWithClientOrServer (servers []webrtc.ICEServer , client bool , opts * ConnOpts ) (* Conn , error ) {
47
+ func newWithClientOrServer (servers []webrtc.ICEServer , client bool , opts * ConnOptions ) (* Conn , error ) {
48
48
if opts == nil {
49
- opts = & ConnOpts {}
49
+ opts = & ConnOptions {}
50
50
}
51
51
52
52
// Enables preference to STUN.
@@ -91,7 +91,7 @@ func newWithClientOrServer(servers []webrtc.ICEServer, client bool, opts *ConnOp
91
91
return conn , nil
92
92
}
93
93
94
- type ConnOpts struct {
94
+ type ConnOptions struct {
95
95
Logger slog.Logger
96
96
97
97
// Enables customization on the underlying WebRTC connection.
@@ -104,7 +104,7 @@ type ConnOpts struct {
104
104
// concurrent-safe webrtc.DataChannel, and standardized errors for connection state.
105
105
type Conn struct {
106
106
rtc * webrtc.PeerConnection
107
- opts * ConnOpts
107
+ opts * ConnOptions
108
108
// Determines whether this connection will send the offer or the answer.
109
109
offerrer bool
110
110
@@ -231,7 +231,7 @@ func (c *Conn) init() error {
231
231
232
232
func (c * Conn ) pingChannel () (* Channel , error ) {
233
233
c .pingOnce .Do (func () {
234
- c .pingChan , c .pingError = c .dialChannel (context .Background (), "ping" , & ChannelOpts {
234
+ c .pingChan , c .pingError = c .dialChannel (context .Background (), "ping" , & ChannelOptions {
235
235
ID : c .pingChannelID ,
236
236
Negotiated : true ,
237
237
OpenOnDisconnect : true ,
@@ -245,7 +245,7 @@ func (c *Conn) pingChannel() (*Channel, error) {
245
245
246
246
func (c * Conn ) pingEchoChannel () (* Channel , error ) {
247
247
c .pingEchoOnce .Do (func () {
248
- c .pingEchoChan , c .pingEchoError = c .dialChannel (context .Background (), "echo" , & ChannelOpts {
248
+ c .pingEchoChan , c .pingEchoError = c .dialChannel (context .Background (), "echo" , & ChannelOptions {
249
249
ID : c .pingEchoChannelID ,
250
250
Negotiated : true ,
251
251
OpenOnDisconnect : true ,
@@ -416,21 +416,21 @@ func (c *Conn) Accept(ctx context.Context) (*Channel, error) {
416
416
case dataChannel = <- c .dcOpenChannel :
417
417
}
418
418
419
- return newChannel (c , dataChannel , & ChannelOpts {}), nil
419
+ return newChannel (c , dataChannel , & ChannelOptions {}), nil
420
420
}
421
421
422
422
// Dial creates a new DataChannel.
423
- func (c * Conn ) Dial (ctx context.Context , label string , opts * ChannelOpts ) (* Channel , error ) {
423
+ func (c * Conn ) Dial (ctx context.Context , label string , opts * ChannelOptions ) (* Channel , error ) {
424
424
if opts == nil {
425
- opts = & ChannelOpts {}
425
+ opts = & ChannelOptions {}
426
426
}
427
427
if opts .ID == c .pingChannelID || opts .ID == c .pingEchoChannelID {
428
428
return nil , xerrors .Errorf ("datachannel id %d and %d are reserved for ping" , c .pingChannelID , c .pingEchoChannelID )
429
429
}
430
430
return c .dialChannel (ctx , label , opts )
431
431
}
432
432
433
- func (c * Conn ) dialChannel (ctx context.Context , label string , opts * ChannelOpts ) (* Channel , error ) {
433
+ func (c * Conn ) dialChannel (ctx context.Context , label string , opts * ChannelOptions ) (* Channel , error ) {
434
434
c .opts .Logger .Debug (ctx , "creating data channel" , slog .F ("label" , label ), slog .F ("opts" , opts ))
435
435
var id * uint16
436
436
if opts .ID != 0 {
0 commit comments