websocket

package
v0.0.0-...-db6c15f Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(route Route, handler Handler)

func Intercept

func Intercept(route Route, interceptor Handler)

func SetErrorReceiver

func SetErrorReceiver(receiver ErrorReceiver)

func SetMessageParser

func SetMessageParser(parser MessageParser)

Types

type ErrorReceiver

type ErrorReceiver func(ctx context.Context, err error)

type Handler

type Handler func(ctx context.Context, message Message, writing chan<- Message) error

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func NewHub

func NewHub(conn *websocket.Conn, readBuffer, writeBuffer int) *Hub

func (*Hub) Run

func (hub *Hub) Run(ctx context.Context)

func (*Hub) SetMaxMessageSize

func (hub *Hub) SetMaxMessageSize(size int64)

func (*Hub) SetPingPeriod

func (hub *Hub) SetPingPeriod(period time.Duration)

func (*Hub) SetReadWait

func (hub *Hub) SetReadWait(wait time.Duration)

func (*Hub) SetWriteWait

func (hub *Hub) SetWriteWait(wait time.Duration)

type Message

type Message interface {
	GetID() string
	GetRoute() Route
	GetPayload() string
}

type MessageParser

type MessageParser func(ctx context.Context, raw []byte) (Message, error)

type Route

type Route string

Jump to

Keyboard shortcuts

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