forked from calebdoxsey/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtcdatachannelstate.go
61 lines (53 loc) · 1.88 KB
/
rtcdatachannelstate.go
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
55
56
57
58
59
60
61
package webrtc
// RTCDataChannelState indicates the state of a data channel.
type RTCDataChannelState int
const (
// RTCDataChannelStateConnecting indicates that the data channel is being
// established. This is the initial state of RTCDataChannel, whether created
// with CreateDataChannel, or dispatched as a part of an RTCDataChannelEvent.
RTCDataChannelStateConnecting RTCDataChannelState = iota + 1
// RTCDataChannelStateOpen indicates that the underlying data transport is
// established and communication is possible.
RTCDataChannelStateOpen
// RTCDataChannelStateClosing indicates that the procedure to close down the
// underlying data transport has started.
RTCDataChannelStateClosing
// RTCDataChannelStateClosed indicates that the underlying data transport
// has been closed or could not be established.
RTCDataChannelStateClosed
)
// This is done this way because of a linter.
const (
rtcDataChannelStateConnectingStr = "connecting"
rtcDataChannelStateOpenStr = "open"
rtcDataChannelStateClosingStr = "closing"
rtcDataChannelStateClosedStr = "closed"
)
func newRTCDataChannelState(raw string) RTCDataChannelState {
switch raw {
case rtcDataChannelStateConnectingStr:
return RTCDataChannelStateConnecting
case rtcDataChannelStateOpenStr:
return RTCDataChannelStateOpen
case rtcDataChannelStateClosingStr:
return RTCDataChannelStateClosing
case rtcDataChannelStateClosedStr:
return RTCDataChannelStateClosed
default:
return RTCDataChannelState(Unknown)
}
}
func (t RTCDataChannelState) String() string {
switch t {
case RTCDataChannelStateConnecting:
return rtcDataChannelStateConnectingStr
case RTCDataChannelStateOpen:
return rtcDataChannelStateOpenStr
case RTCDataChannelStateClosing:
return rtcDataChannelStateClosingStr
case RTCDataChannelStateClosed:
return rtcDataChannelStateClosedStr
default:
return ErrUnknownType.Error()
}
}