ice.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package ice
  2. // ConnectionState is an enum showing the state of a ICE Connection
  3. type ConnectionState int
  4. // List of supported States
  5. const (
  6. // ConnectionStateNew ICE agent is gathering addresses
  7. ConnectionStateNew = iota + 1
  8. // ConnectionStateChecking ICE agent has been given local and remote candidates, and is attempting to find a match
  9. ConnectionStateChecking
  10. // ConnectionStateConnected ICE agent has a pairing, but is still checking other pairs
  11. ConnectionStateConnected
  12. // ConnectionStateCompleted ICE agent has finished
  13. ConnectionStateCompleted
  14. // ConnectionStateFailed ICE agent never could successfully connect
  15. ConnectionStateFailed
  16. // ConnectionStateDisconnected ICE agent connected successfully, but has entered a failed state
  17. ConnectionStateDisconnected
  18. // ConnectionStateClosed ICE agent has finished and is no longer handling requests
  19. ConnectionStateClosed
  20. )
  21. func (c ConnectionState) String() string {
  22. switch c {
  23. case ConnectionStateNew:
  24. return "New"
  25. case ConnectionStateChecking:
  26. return "Checking"
  27. case ConnectionStateConnected:
  28. return "Connected"
  29. case ConnectionStateCompleted:
  30. return "Completed"
  31. case ConnectionStateFailed:
  32. return "Failed"
  33. case ConnectionStateDisconnected:
  34. return "Disconnected"
  35. case ConnectionStateClosed:
  36. return "Closed"
  37. default:
  38. return "Invalid"
  39. }
  40. }
  41. // GatheringState describes the state of the candidate gathering process
  42. type GatheringState int
  43. const (
  44. // GatheringStateNew indicates candidate gatering is not yet started
  45. GatheringStateNew GatheringState = iota + 1
  46. // GatheringStateGathering indicates candidate gatering is ongoing
  47. GatheringStateGathering
  48. // GatheringStateComplete indicates candidate gatering has been completed
  49. GatheringStateComplete
  50. )
  51. func (t GatheringState) String() string {
  52. switch t {
  53. case GatheringStateNew:
  54. return "new"
  55. case GatheringStateGathering:
  56. return "gathering"
  57. case GatheringStateComplete:
  58. return "complete"
  59. default:
  60. return ErrUnknownType.Error()
  61. }
  62. }