uwebsocket

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientNotFound = errors.New("client not found")
View Source
var KEY_DOES_NOT_EXIST_ERR = errors.New("key does not exist")
View Source
var KEY_HAS_WRONG_TYPE_ERR = errors.New("key has wrong type")

Functions

This section is empty.

Types

type ClientAttributes

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

func NewClientAttributes added in v0.0.13

func NewClientAttributes() *ClientAttributes

func (*ClientAttributes) GetBool added in v0.0.13

func (c *ClientAttributes) GetBool(key string) (bool, error)

func (*ClientAttributes) GetString added in v0.0.13

func (c *ClientAttributes) GetString(key string) (string, error)

func (*ClientAttributes) HasMatch added in v0.0.10

func (c *ClientAttributes) HasMatch(key string, value string) bool

func (*ClientAttributes) IsFlagSet added in v0.0.10

func (c *ClientAttributes) IsFlagSet(key string) bool

func (*ClientAttributes) SetBool added in v0.0.13

func (c *ClientAttributes) SetBool(key string, value bool) *ClientAttributes

func (*ClientAttributes) SetString added in v0.0.13

func (c *ClientAttributes) SetString(key string, value string) *ClientAttributes

func (*ClientAttributes) String added in v0.0.13

func (c *ClientAttributes) String() string

type ClientMessage

type ClientMessage struct {
	ClientGUID string
	Message    []byte
}

type Handler

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

func NewHandler added in v0.0.14

func NewHandler(opts ...HandlerOption) Handler

type HandlerOption added in v0.0.14

type HandlerOption interface {
	// contains filtered or unexported methods
}

func WithClientAttributes added in v0.0.14

func WithClientAttributes(f func(hub *WebSocketHub, r *http.Request) (*ClientAttributes, error)) HandlerOption

func WithOnConnect added in v0.0.14

func WithOnConnect(f func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, ctx context.Context)) HandlerOption

func WithOnError added in v0.0.14

func WithOnError(f func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, err error, ctx context.Context)) HandlerOption

func WithOnIncomingMessage added in v0.0.14

func WithOnIncomingMessage(f func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, msg ClientMessage, ctx context.Context)) HandlerOption

func WithUhttpHandler added in v0.0.14

func WithUhttpHandler(h uhttp.Handler) HandlerOption

func WithWelcomeMessages added in v0.0.14

func WithWelcomeMessages(f func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, ctx context.Context) ([][]byte, error)) HandlerOption

type WebSocketClient

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

Client is a middleman between the websocket connection and the hub.

type WebSocketHub

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

func CreateHubAndRunInBackground

func CreateHubAndRunInBackground(u *uhttp.UHTTP, messageType int, ctx context.Context) *WebSocketHub

func NewWebSocketHub

func NewWebSocketHub(u *uhttp.UHTTP, messageType int, ctx context.Context) *WebSocketHub

func (*WebSocketHub) Handle

func (h *WebSocketHub) Handle(pattern string, handler Handler)

func (*WebSocketHub) Run

func (h *WebSocketHub) Run()

func (*WebSocketHub) SendToAllWithFlagAsync added in v0.0.14

func (h *WebSocketHub) SendToAllWithFlagAsync(flag string, message []byte, ctx context.Context)

func (*WebSocketHub) SendToAllWithFlagSync added in v0.0.13

func (h *WebSocketHub) SendToAllWithFlagSync(flag string, message []byte, ctx context.Context) error

func (*WebSocketHub) SendToAllWithMatchAsync added in v0.0.14

func (h *WebSocketHub) SendToAllWithMatchAsync(key string, value string, message []byte, ctx context.Context)

func (*WebSocketHub) SendToAllWithMatchSync added in v0.0.13

func (h *WebSocketHub) SendToAllWithMatchSync(key string, value string, message []byte, ctx context.Context) error

func (*WebSocketHub) SendToClientSync added in v0.0.13

func (h *WebSocketHub) SendToClientSync(clientGUID string, message []byte, ctx context.Context) error

func (*WebSocketHub) SendWithFilterAsync added in v0.0.14

func (h *WebSocketHub) SendWithFilterAsync(filterFunc func(clientGUID string, attrs *ClientAttributes) bool, message []byte, ctx context.Context)

func (*WebSocketHub) SendWithFilterSync added in v0.0.13

func (h *WebSocketHub) SendWithFilterSync(filterFunc func(clientGUID string, attrs *ClientAttributes) bool, message []byte, ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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