mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
@@ -4,7 +4,6 @@ package ice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"strings"
|
||||
@@ -1303,41 +1302,3 @@ func (a *Agent) GetRemoteCandidatesStats() []CandidateStats {
|
||||
}
|
||||
return <-resultChan
|
||||
}
|
||||
|
||||
// Role represents ICE agent role, which can be controlling or controlled.
|
||||
type Role byte
|
||||
|
||||
// UnmarshalText implements TextUnmarshaler.
|
||||
func (r *Role) UnmarshalText(text []byte) error {
|
||||
switch string(text) {
|
||||
case "controlling":
|
||||
*r = Controlling
|
||||
case "controlled":
|
||||
*r = Controlled
|
||||
default:
|
||||
return fmt.Errorf("unknown role %q", text)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText implements TextMarshaler.
|
||||
func (r Role) MarshalText() (text []byte, err error) {
|
||||
return []byte(r.String()), nil
|
||||
}
|
||||
|
||||
func (r Role) String() string {
|
||||
switch r {
|
||||
case Controlling:
|
||||
return "controlling"
|
||||
case Controlled:
|
||||
return "controlled"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// Possible ICE agent roles.
|
||||
const (
|
||||
Controlling Role = iota
|
||||
Controlled
|
||||
)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package ice
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Role represents ICE agent role, which can be controlling or controlled.
|
||||
type Role byte
|
||||
|
||||
// Possible ICE agent roles.
|
||||
const (
|
||||
Controlling Role = iota
|
||||
Controlled
|
||||
)
|
||||
|
||||
// UnmarshalText implements TextUnmarshaler.
|
||||
func (r *Role) UnmarshalText(text []byte) error {
|
||||
switch string(text) {
|
||||
case "controlling":
|
||||
*r = Controlling
|
||||
case "controlled":
|
||||
*r = Controlled
|
||||
default:
|
||||
return fmt.Errorf("unknown role %q", text)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText implements TextMarshaler.
|
||||
func (r Role) MarshalText() (text []byte, err error) {
|
||||
return []byte(r.String()), nil
|
||||
}
|
||||
|
||||
func (r Role) String() string {
|
||||
switch r {
|
||||
case Controlling:
|
||||
return "controlling"
|
||||
case Controlled:
|
||||
return "controlled"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user