eio

package module
v0.0.0-...-ebefb51 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 12 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

engine.io

GoDoc License

Installation

Use go get.

go get github.com/funcards/engine.io

Then import engine.io package into your own code.

import "github.com/funcards/engine.io"

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

View Source
const (
	TopicOpen          = "open"
	TopicClose         = "close"
	TopicConnection    = "connection"
	TopicDisconnect    = "disconnect"
	TopicDisconnecting = "disconnecting"
	TopicHeartbeat     = "heartbeat"
	TopicData          = "data"
	TopicMessage       = "message"
	TopicPacket        = "packet"
	TopicError         = "error"
)
View Source
const HandshakeJSON = "{\"sid\": \"%s\", \"upgrades\": [], \"pingInterval\": %d, \"pingTimeout\": %d}"

Variables

This section is empty.

Functions

func NewEmitter

func NewEmitter() *wrapEmitter

func NewSID

func NewSID() string

func NewServer

func NewServer(cfg Config, logger *zap.Logger) *server

func NewServerWithInterceptor

func NewServerWithInterceptor(cfg Config, logger *zap.Logger, interceptor HandshakeInterceptor) *server

func NewSocket

func NewSocket(cfg Config, ws WebSocket, logger *zap.Logger) *socket

Types

type Config

type Config struct {
	PingInterval  time.Duration `yaml:"ping_interval" env-default:"30s" env:"EIO_PING_INTERVAL"`
	PingTimeout   time.Duration `yaml:"ping_timeout" env-default:"1m" env:"EIO_PING_TIMEOUT"`
	InitialPacket *eiop.Packet  `yaml:"initial_packet"`
}

type Emitter

type Emitter interface {
	Use(pattern string, middlewares ...func(event *emitter.Event))
	On(topic string, middlewares ...func(event *emitter.Event)) <-chan emitter.Event
	Once(topic string, middlewares ...func(event *emitter.Event)) <-chan emitter.Event
	Off(topic string, channels ...<-chan emitter.Event)
	Listeners(topic string) []<-chan emitter.Event
	Topics() []string
	Emit(topic string, args ...any) chan struct{}
	Fire(topic string, args ...any)
}

type HandshakeInterceptor

type HandshakeInterceptor func(query url.Values, headers map[string]string) bool

type Server

type Server interface {
	Emitter

	Cfg() Config
	Shutdown()
	HandleWebSocket(ws WebSocket) error
}

type Socket

type Socket interface {
	io.Closer
	Emitter

	SID() string
	State() State
	Query() url.Values
	Headers() map[string]string
	Send(packet eiop.Packet)
}

type State

type State byte
const (
	Opening State = iota
	Open
	Closing
	Closed
)

type WebSocket

type WebSocket interface {
	io.Closer
	Emitter

	Query() url.Values
	Headers() map[string]string
	Write(packet eiop.Packet)
}

Jump to

Keyboard shortcuts

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