github.com/pion/webrtc/v3@v3.2.24/sctptransportstate.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package webrtc 5 6 // SCTPTransportState indicates the state of the SCTP transport. 7 type SCTPTransportState int 8 9 const ( 10 // SCTPTransportStateConnecting indicates the SCTPTransport is in the 11 // process of negotiating an association. This is the initial state of the 12 // SCTPTransportState when an SCTPTransport is created. 13 SCTPTransportStateConnecting SCTPTransportState = iota + 1 14 15 // SCTPTransportStateConnected indicates the negotiation of an 16 // association is completed. 17 SCTPTransportStateConnected 18 19 // SCTPTransportStateClosed indicates a SHUTDOWN or ABORT chunk is 20 // received or when the SCTP association has been closed intentionally, 21 // such as by closing the peer connection or applying a remote description 22 // that rejects data or changes the SCTP port. 23 SCTPTransportStateClosed 24 ) 25 26 // This is done this way because of a linter. 27 const ( 28 sctpTransportStateConnectingStr = "connecting" 29 sctpTransportStateConnectedStr = "connected" 30 sctpTransportStateClosedStr = "closed" 31 ) 32 33 func newSCTPTransportState(raw string) SCTPTransportState { 34 switch raw { 35 case sctpTransportStateConnectingStr: 36 return SCTPTransportStateConnecting 37 case sctpTransportStateConnectedStr: 38 return SCTPTransportStateConnected 39 case sctpTransportStateClosedStr: 40 return SCTPTransportStateClosed 41 default: 42 return SCTPTransportState(Unknown) 43 } 44 } 45 46 func (s SCTPTransportState) String() string { 47 switch s { 48 case SCTPTransportStateConnecting: 49 return sctpTransportStateConnectingStr 50 case SCTPTransportStateConnected: 51 return sctpTransportStateConnectedStr 52 case SCTPTransportStateClosed: 53 return sctpTransportStateClosedStr 54 default: 55 return ErrUnknownType.Error() 56 } 57 }