enums.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. export enum ConnectionType {
  2. Data = "data",
  3. Media = "media",
  4. }
  5. export enum PeerErrorType {
  6. /**
  7. * The client's browser does not support some or all WebRTC features that you are trying to use.
  8. */
  9. BrowserIncompatible = "browser-incompatible",
  10. /**
  11. * You've already disconnected this peer from the server and can no longer make any new connections on it.
  12. */
  13. Disconnected = "disconnected",
  14. /**
  15. * The ID passed into the Peer constructor contains illegal characters.
  16. */
  17. InvalidID = "invalid-id",
  18. /**
  19. * The API key passed into the Peer constructor contains illegal characters or is not in the system (cloud server only).
  20. */
  21. InvalidKey = "invalid-key",
  22. /**
  23. * Lost or cannot establish a connection to the signalling server.
  24. */
  25. Network = "network",
  26. /**
  27. * The peer you're trying to connect to does not exist.
  28. */
  29. PeerUnavailable = "peer-unavailable",
  30. /**
  31. * PeerJS is being used securely, but the cloud server does not support SSL. Use a custom PeerServer.
  32. */
  33. SslUnavailable = "ssl-unavailable",
  34. /**
  35. * Unable to reach the server.
  36. */
  37. ServerError = "server-error",
  38. /**
  39. * An error from the underlying socket.
  40. */
  41. SocketError = "socket-error",
  42. /**
  43. * The underlying socket closed unexpectedly.
  44. */
  45. SocketClosed = "socket-closed",
  46. /**
  47. * The ID passed into the Peer constructor is already taken.
  48. *
  49. * :::caution
  50. * This error is not fatal if your peer has open peer-to-peer connections.
  51. * This can happen if you attempt to {@apilink Peer.reconnect} a peer that has been disconnected from the server,
  52. * but its old ID has now been taken.
  53. * :::
  54. */
  55. UnavailableID = "unavailable-id",
  56. /**
  57. * Native WebRTC errors.
  58. */
  59. WebRTC = "webrtc",
  60. }
  61. export enum BaseConnectionErrorType {
  62. NegotiationFailed = "negotiation-failed",
  63. ConnectionClosed = "connection-closed",
  64. }
  65. export enum DataConnectionErrorType {
  66. NotOpenYet = "not-open-yet",
  67. MessageToBig = "message-too-big",
  68. }
  69. export enum SerializationType {
  70. Binary = "binary",
  71. BinaryUTF8 = "binary-utf8",
  72. JSON = "json",
  73. None = "raw",
  74. }
  75. export enum SocketEventType {
  76. Message = "message",
  77. Disconnected = "disconnected",
  78. Error = "error",
  79. Close = "close",
  80. }
  81. export enum ServerMessageType {
  82. Heartbeat = "HEARTBEAT",
  83. Candidate = "CANDIDATE",
  84. Offer = "OFFER",
  85. Answer = "ANSWER",
  86. Open = "OPEN", // The connection to the server is open.
  87. Error = "ERROR", // Server error.
  88. IdTaken = "ID-TAKEN", // The selected ID is taken.
  89. InvalidKey = "INVALID-KEY", // The given API key cannot be found.
  90. Leave = "LEAVE", // Another peer has closed its connection to this peer.
  91. Expire = "EXPIRE", // The offer sent to a peer has expired without response.
  92. }