sctptransportstate.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package webrtc
  2. // SCTPTransportState indicates the state of the SCTP transport.
  3. type SCTPTransportState int
  4. const (
  5. // SCTPTransportStateConnecting indicates the SCTPTransport is in the
  6. // process of negotiating an association. This is the initial state of the
  7. // SCTPTransportState when an SCTPTransport is created.
  8. SCTPTransportStateConnecting SCTPTransportState = iota + 1
  9. // SCTPTransportStateConnected indicates the negotiation of an
  10. // association is completed.
  11. SCTPTransportStateConnected
  12. // SCTPTransportStateClosed indicates a SHUTDOWN or ABORT chunk is
  13. // received or when the SCTP association has been closed intentionally,
  14. // such as by closing the peer connection or applying a remote description
  15. // that rejects data or changes the SCTP port.
  16. SCTPTransportStateClosed
  17. )
  18. // This is done this way because of a linter.
  19. const (
  20. sctpTransportStateConnectingStr = "connecting"
  21. sctpTransportStateConnectedStr = "connected"
  22. sctpTransportStateClosedStr = "closed"
  23. )
  24. func newSCTPTransportState(raw string) SCTPTransportState {
  25. switch raw {
  26. case sctpTransportStateConnectingStr:
  27. return SCTPTransportStateConnecting
  28. case sctpTransportStateConnectedStr:
  29. return SCTPTransportStateConnected
  30. case sctpTransportStateClosedStr:
  31. return SCTPTransportStateClosed
  32. default:
  33. return SCTPTransportState(Unknown)
  34. }
  35. }
  36. func (s SCTPTransportState) String() string {
  37. switch s {
  38. case SCTPTransportStateConnecting:
  39. return sctpTransportStateConnectingStr
  40. case SCTPTransportStateConnected:
  41. return sctpTransportStateConnectedStr
  42. case SCTPTransportStateClosed:
  43. return sctpTransportStateClosedStr
  44. default:
  45. return ErrUnknownType.Error()
  46. }
  47. }