xsocketio

package
v0.0.0-...-65008d1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestChecker engineio.CheckerFunc = func(req *http.Request) (http.Header, error) {
	token := common.Setting(`socketio`).String(`token`)
	if len(token) == 0 {
		return nil, nil
	}
	post := req.Header.Get(`Token`)
	if len(post) == 0 {
		post = req.URL.Query().Get(`token`)
	}
	if token != post {
		if log.IsEnabled(log.LevelDebug) {
			log.Debugf(`[socketIO] invalid token: %q`, post)
			log.Debugf(`[socketIO] request headers: %+v`, req.Header)
		}
		return nil, echo.NewError(`invalid token`, code.InvalidToken)
	}
	return nil, nil
}

Functions

func Close

func Close(namespace string) bool

func CloseAll

func CloseAll()

func OnConnect

func OnConnect(fns ...func(ctx echo.Context, conn socketio.Conn) error)

func OnDisconnect

func OnDisconnect(fns ...func(ctx echo.Context, conn socketio.Conn, msg string))

func OnError

func OnError(fns ...func(ctx echo.Context, conn socketio.Conn, e error))

func OnEvent

func OnEvent(fns ...func(esi.IWrapper))

func OnNSConnect

func OnNSConnect(nsp string, fns ...func(ctx echo.Context, conn socketio.Conn) error)

func OnNSDisconnect

func OnNSDisconnect(nsp string, fns ...func(ctx echo.Context, conn socketio.Conn, msg string))

func OnNSError

func OnNSError(nsp string, fns ...func(ctx echo.Context, conn socketio.Conn, e error))

func OnNSEvent

func OnNSEvent(nsp string, fns ...func(esi.IWrapper))

func RegisterRoute

func RegisterRoute(e echo.RouteRegister, cfg *Config, s ...func(*middleware.CORSConfig))

func SocketIO

func SocketIO(namespace string, cfg *Config) *esi.Wrapper

Types

type Config

type Config struct {
	EnableRedis   bool   `json:"enableRedis"`
	RedisDB       int    `json:"redisDB"`
	RedisAddr     string `json:"redisAddr"`
	RedisPrefix   string `json:"redisPrefix"`
	RedisNetwork  string `json:"redisNetwork"`
	RedisPassword string `json:"redisPassword"`
}

func GetConfig

func GetConfig() *Config

func NewConfig

func NewConfig() *Config

func (*Config) FromStore

func (c *Config) FromStore(v echo.H) *Config

Jump to

Keyboard shortcuts

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