engine

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2022 License: MIT Imports: 15 Imported by: 2

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

func NewServer

func NewServer(opt interface{}) *server

Server New.

Types

type Server

type Server interface {
	events.EventEmitter

	SetHttpServer(*types.HttpServer)

	HttpServer() *types.HttpServer
	Opts() *config.ServerOptions
	Clients() *sync.Map
	ClientsCount() uint64

	// Returns a list of available transports for upgrade given a certain transport.
	Upgrades(string) *types.Set

	// 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, interface{})

	// 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 interface{}) Server

Captures upgrade requests for a types.HttpServer.

func Listen

func Listen(addr string, options interface{}, fn types.Callable) Server

Creates an http.Server exclusively used for WS upgrades.

func New

func New(server interface{}, args ...interface{}) Server

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL