-
Notifications
You must be signed in to change notification settings - Fork 351
Description
Summary
As preparation for tackling TCP support TURN protocol (#1), TURN client implementation needs to be able to take net.Conn in addition to net.PacketConn.
Motivation
See #1.
Proposal
Current TURN Client design assumes that an instance of Client is created per socket (net.PacketConn). See Pion: TURN Client Refactor.
ClientConfig takes a parameter, net.PacketConn only, which needs to be changed.
Proposed change is to introduce an interface, turn.Conn which wraps both net.PacketConn and net.Conn.
// Conn a network connection interface with TURN server.
type Conn interface {
LocalAddr() net.Addr // used to determine transport type and IP version
}Justification: to prevent a user from trying to pass both net.PacketConn and net.Conn. (Client can only handle one underlying socket).
Above code won't work due to "duplicate method". We need to manually define methods.
Inside NetClient(), use type-switch to determine which transport protocol the app wants to use.