summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/webrtc/v3/sctptransportstate.go
blob: 8dc79416240684b6c39cb58af3efd7dc8b865098 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package webrtc

// SCTPTransportState indicates the state of the SCTP transport.
type SCTPTransportState int

const (
	// SCTPTransportStateConnecting indicates the SCTPTransport is in the
	// process of negotiating an association. This is the initial state of the
	// SCTPTransportState when an SCTPTransport is created.
	SCTPTransportStateConnecting SCTPTransportState = iota + 1

	// SCTPTransportStateConnected indicates the negotiation of an
	// association is completed.
	SCTPTransportStateConnected

	// SCTPTransportStateClosed indicates a SHUTDOWN or ABORT chunk is
	// received or when the SCTP association has been closed intentionally,
	// such as by closing the peer connection or applying a remote description
	// that rejects data or changes the SCTP port.
	SCTPTransportStateClosed
)

// This is done this way because of a linter.
const (
	sctpTransportStateConnectingStr = "connecting"
	sctpTransportStateConnectedStr  = "connected"
	sctpTransportStateClosedStr     = "closed"
)

func newSCTPTransportState(raw string) SCTPTransportState {
	switch raw {
	case sctpTransportStateConnectingStr:
		return SCTPTransportStateConnecting
	case sctpTransportStateConnectedStr:
		return SCTPTransportStateConnected
	case sctpTransportStateClosedStr:
		return SCTPTransportStateClosed
	default:
		return SCTPTransportState(Unknown)
	}
}

func (s SCTPTransportState) String() string {
	switch s {
	case SCTPTransportStateConnecting:
		return sctpTransportStateConnectingStr
	case SCTPTransportStateConnected:
		return sctpTransportStateConnectedStr
	case SCTPTransportStateClosed:
		return sctpTransportStateClosedStr
	default:
		return ErrUnknownType.Error()
	}
}