aliases.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package websocket
  2. import (
  3. "github.com/kataras/neffos"
  4. "github.com/kataras/neffos/gobwas"
  5. "github.com/kataras/neffos/gorilla"
  6. "github.com/kataras/neffos/stackexchange/redis"
  7. )
  8. type (
  9. // Dialer is the definition type of a dialer, gorilla or gobwas or custom.
  10. // It is the second parameter of the `Dial` function.
  11. Dialer = neffos.Dialer
  12. // GorillaDialerOptions is just an alias for the `gobwas/ws.Dialer` struct type.
  13. GorillaDialerOptions = gorilla.Options
  14. // GobwasDialerOptions is just an alias for the `gorilla/websocket.Dialer` struct type.
  15. GobwasDialerOptions = gobwas.Options
  16. // GobwasHeader is an alias to the adapter that allows the use of `http.Header` as
  17. // handshake headers.
  18. GobwasHeader = gobwas.Header
  19. // Conn describes the main websocket connection's functionality.
  20. // Its `Connection` will return a new `NSConn` instance.
  21. // Each connection can connect to one or more declared namespaces.
  22. // Each `NSConn` can join to multiple rooms.
  23. Conn = neffos.Conn
  24. // NSConn describes a connection connected to a specific namespace,
  25. // it emits with the `Message.Namespace` filled and it can join to multiple rooms.
  26. // A single `Conn` can be connected to one or more namespaces,
  27. // each connected namespace is described by this structure.
  28. NSConn = neffos.NSConn
  29. // Room describes a connected connection to a room,
  30. // emits messages with the `Message.Room` filled to the specific room
  31. // and `Message.Namespace` to the underline `NSConn`'s namespace.
  32. Room = neffos.Room
  33. // CloseError can be used to send and close a remote connection in the event callback's return statement.
  34. CloseError = neffos.CloseError
  35. // MessageHandlerFunc is the definition type of the events' callback.
  36. // Its error can be written to the other side on specific events,
  37. // i.e on `OnNamespaceConnect` it will abort a remote namespace connection.
  38. // See examples for more.
  39. MessageHandlerFunc = neffos.MessageHandlerFunc
  40. // ConnHandler is the interface which namespaces and events can be retrieved through.
  41. ConnHandler = neffos.ConnHandler
  42. // Events completes the `ConnHandler` interface.
  43. // It is a map which its key is the event name
  44. // and its value the event's callback.
  45. //
  46. // Events type completes the `ConnHandler` itself therefore,
  47. // can be used as standalone value on the `New` and `Dial` functions
  48. // to register events on empty namespace as well.
  49. //
  50. // See `Namespaces`, `New` and `Dial` too.
  51. Events = neffos.Events
  52. // Namespaces completes the `ConnHandler` interface.
  53. // Can be used to register one or more namespaces on the `New` and `Dial` functions.
  54. // The key is the namespace literal and the value is the `Events`,
  55. // a map with event names and their callbacks.
  56. //
  57. // See `WithTimeout`, `New` and `Dial` too.
  58. Namespaces = neffos.Namespaces
  59. // WithTimeout completes the `ConnHandler` interface.
  60. // Can be used to register namespaces and events or just events on an empty namespace
  61. // with Read and Write timeouts.
  62. //
  63. // See `New` and `Dial`.
  64. WithTimeout = neffos.WithTimeout
  65. // Struct completes the `ConnHandler` interface.
  66. // It uses a structure to register a specific namespace and its events.
  67. Struct = neffos.Struct
  68. // StructInjector can be used to customize the value creation that can is used on serving events.
  69. StructInjector = neffos.StructInjector
  70. // The Message is the structure which describes the incoming and outcoming data.
  71. // Emitter's "body" argument is the `Message.Body` field.
  72. // Emitter's return non-nil error is the `Message.Err` field.
  73. // If native message sent then the `Message.Body` is filled with the body and
  74. // when incoming native message then the `Message.Event` is the `OnNativeMessage`,
  75. // native messages are allowed only when an empty namespace("") and its `OnNativeMessage` callback are present.
  76. Message = neffos.Message
  77. // StackExchange is an optional interface
  78. // that can be used to change the way neffos
  79. // sends messages to its clients, i.e
  80. // communication between multiple neffos servers.
  81. //
  82. // See `NewRedisStackExchange` to create a new redis StackExchange.
  83. StackExchange = neffos.StackExchange
  84. // RedisStackExchange is a `neffos.StackExchange` for redis.
  85. RedisStackExchange = redis.StackExchange
  86. // RedisConfig is used on the `NewRedisStackExchange` package-level function.
  87. // Can be used to customize the redis client dialer.
  88. RedisConfig = redis.Config
  89. )