ws

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(data []byte, filter *Filter) error

func BroadcastBinary

func BroadcastBinary(data []byte, filter *Filter) error

func Init

func Init(ctx contextx.Context, r *gin.RouterGroup, opfs ...func(opt Options))

Types

type Filter

type Filter struct {
	Keys map[string]map[interface{}]struct{}
	// contains filtered or unexported fields
}

func NewBlacklistFilter

func NewBlacklistFilter(key string, vals ...interface{}) *Filter

func NewWhitelistFilter

func NewWhitelistFilter(key string, vals ...interface{}) *Filter

func (*Filter) AddKeys

func (f *Filter) AddKeys(key string, vals ...interface{})

type Options

type Options interface {
	SetCallTimeout(t time.Duration)
	SetRelativePath(relativePath string)
	SetKeys(keys ...string)
	SetAuth(auth func(c *gin.Context))

	HandleConnect(fn func(*melody.Session))
	HandleDisconnect(fn func(*melody.Session))
	HandlePong(fn func(*melody.Session))
	HandleMessage(fn func(*melody.Session, []byte))
	HandleMessageBinary(fn func(*melody.Session, []byte))
	HandleSentMessage(fn func(*melody.Session, []byte))
	HandleSentMessageBinary(fn func(*melody.Session, []byte))
	HandleError(fn func(*melody.Session, error))
	HandleClose(fn func(*melody.Session, int, string) error)
}

Jump to

Keyboard shortcuts

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