@@ -32,20 +32,20 @@ var (
32
32
)
33
33
34
34
// Client creates a new client connection.
35
- func Client (servers []webrtc.ICEServer , opts * ConnOpts ) (* Conn , error ) {
35
+ func Client (servers []webrtc.ICEServer , opts * ConnOptions ) (* Conn , error ) {
36
36
return newWithClientOrServer (servers , true , opts )
37
37
}
38
38
39
39
// Server creates a new server connection.
40
- func Server (servers []webrtc.ICEServer , opts * ConnOpts ) (* Conn , error ) {
40
+ func Server (servers []webrtc.ICEServer , opts * ConnOptions ) (* Conn , error ) {
41
41
return newWithClientOrServer (servers , false , opts )
42
42
}
43
43
44
44
// newWithClientOrServer constructs a new connection with the client option.
45
45
// nolint:revive
46
- func newWithClientOrServer (servers []webrtc.ICEServer , client bool , opts * ConnOpts ) (* Conn , error ) {
46
+ func newWithClientOrServer (servers []webrtc.ICEServer , client bool , opts * ConnOptions ) (* Conn , error ) {
47
47
if opts == nil {
48
- opts = & ConnOpts {}
48
+ opts = & ConnOptions {}
49
49
}
50
50
51
51
// Enables preference to STUN.
@@ -90,7 +90,7 @@ func newWithClientOrServer(servers []webrtc.ICEServer, client bool, opts *ConnOp
90
90
return conn , nil
91
91
}
92
92
93
- type ConnOpts struct {
93
+ type ConnOptions struct {
94
94
Logger slog.Logger
95
95
96
96
// Enables customization on the underlying WebRTC connection.
@@ -103,7 +103,7 @@ type ConnOpts struct {
103
103
// concurrent-safe webrtc.DataChannel, and standardized errors for connection state.
104
104
type Conn struct {
105
105
rtc * webrtc.PeerConnection
106
- opts * ConnOpts
106
+ opts * ConnOptions
107
107
// Determines whether this connection will send the offer or the answer.
108
108
offerrer bool
109
109
@@ -203,7 +203,7 @@ func (c *Conn) init() error {
203
203
204
204
func (c * Conn ) pingChannel () (* Channel , error ) {
205
205
c .pingOnce .Do (func () {
206
- c .pingChan , c .pingError = c .dialChannel (context .Background (), "ping" , & ChannelOpts {
206
+ c .pingChan , c .pingError = c .dialChannel (context .Background (), "ping" , & ChannelOptions {
207
207
ID : c .pingChannelID ,
208
208
Negotiated : true ,
209
209
OpenOnDisconnect : true ,
@@ -217,7 +217,7 @@ func (c *Conn) pingChannel() (*Channel, error) {
217
217
218
218
func (c * Conn ) pingEchoChannel () (* Channel , error ) {
219
219
c .pingEchoOnce .Do (func () {
220
- c .pingEchoChan , c .pingEchoError = c .dialChannel (context .Background (), "echo" , & ChannelOpts {
220
+ c .pingEchoChan , c .pingEchoError = c .dialChannel (context .Background (), "echo" , & ChannelOptions {
221
221
ID : c .pingEchoChannelID ,
222
222
Negotiated : true ,
223
223
OpenOnDisconnect : true ,
@@ -377,21 +377,21 @@ func (c *Conn) Accept(ctx context.Context) (*Channel, error) {
377
377
case dataChannel = <- c .dcOpenChannel :
378
378
}
379
379
380
- return newChannel (c , dataChannel , & ChannelOpts {}), nil
380
+ return newChannel (c , dataChannel , & ChannelOptions {}), nil
381
381
}
382
382
383
383
// Dial creates a new DataChannel.
384
- func (c * Conn ) Dial (ctx context.Context , label string , opts * ChannelOpts ) (* Channel , error ) {
384
+ func (c * Conn ) Dial (ctx context.Context , label string , opts * ChannelOptions ) (* Channel , error ) {
385
385
if opts == nil {
386
- opts = & ChannelOpts {}
386
+ opts = & ChannelOptions {}
387
387
}
388
388
if opts .ID == c .pingChannelID || opts .ID == c .pingEchoChannelID {
389
389
return nil , xerrors .Errorf ("datachannel id %d and %d are reserved for ping" , c .pingChannelID , c .pingEchoChannelID )
390
390
}
391
391
return c .dialChannel (ctx , label , opts )
392
392
}
393
393
394
- func (c * Conn ) dialChannel (ctx context.Context , label string , opts * ChannelOpts ) (* Channel , error ) {
394
+ func (c * Conn ) dialChannel (ctx context.Context , label string , opts * ChannelOptions ) (* Channel , error ) {
395
395
c .opts .Logger .Debug (ctx , "creating data channel" , slog .F ("label" , label ), slog .F ("opts" , opts ))
396
396
var id * uint16
397
397
if opts .ID != 0 {
0 commit comments