Documentation
¶
Index ¶
Constants ¶
View Source
const ( OK_REQUEST int = -1 UNKNOWN_TRANSPORT int = 0 UNKNOWN_SID int = 1 BAD_HANDSHAKE_METHOD int = 2 BAD_REQUEST int = 3 FORBIDDEN int = 4 UNSUPPORTED_PROTOCOL_VERSION int = 5 )
Protocol errors mappings.
View Source
const Protocol = 4
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Middleware ¶ added in v1.4.0
type Middleware func(*types.HttpContext, func(error))
Middleware functions are functions that have access to the *types.HttpContext and the next middleware function in the application's context cycle.
type Server ¶
type Server interface {
events.EventEmitter
// Captures upgrade requests for a http.Handler, Need to handle server shutdown disconnecting client connections.
http.Handler
SetHttpServer(*types.HttpServer)
HttpServer() *types.HttpServer
Opts() config.ServerOptionsInterface
Clients() *types.Map[string, Socket]
ClientsCount() uint64
// Returns a list of available transports for upgrade given a certain transport.
Upgrades(string) *types.Set[string]
// Adds a new middleware.
Use(Middleware)
// Closes all clients.
Close() Server
// Handles an Engine.IO HTTP request.
HandleRequest(*types.HttpContext)
// Handles an Engine.IO HTTP Upgrade.
HandleUpgrade(*types.HttpContext)
// Captures upgrade requests for a *types.HttpServer.
Attach(*types.HttpServer, any)
// generate a socket id.
// Overwrite this method to generate your custom socket id
GenerateId(*types.HttpContext) (string, error)
}
func Attach ¶
func Attach(server *types.HttpServer, options any) Server
Captures upgrade requests for a types.HttpServer.
type Socket ¶
type Socket interface {
events.EventEmitter
SetReadyState(string)
Id() string
ReadyState() string
Protocol() int
Server() Server
Request() *types.HttpContext
RemoteAddress() string
Upgraded() bool
Upgrading() bool
Transport() transports.Transport
// Upgrades socket to the given transport
MaybeUpgrade(transports.Transport)
// Sends a message packet.
Send(io.Reader, *packet.Options, func(transports.Transport)) Socket
Write(io.Reader, *packet.Options, func(transports.Transport)) Socket
// Closes the socket and underlying transport.
Close(bool)
}
func NewSocket ¶
func NewSocket(id string, server Server, transport transports.Transport, ctx *types.HttpContext, protocol int) Socket
Client class.
Click to show internal directories.
Click to hide internal directories.