uwebsocket

package module
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientAttributesFunc added in v0.0.3

func ClientAttributesFunc(clientAttributesFunc func(hub *WebSocketHub, r *http.Request) (ClientAttributes, error)) *func(hub *WebSocketHub, r *http.Request) (ClientAttributes, error)

func OnConnect

func OnConnect(onConnectFunc func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, r *http.Request)) *func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, r *http.Request)

func OnDisconnect added in v0.0.5

func OnDisconnect(onDisconnectFunc func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, err error)) *func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, err error)

func OnError added in v0.0.5

func OnError(onErrorFunc func(err error)) *func(err error)

func SetConfig

func SetConfig(_config Config)

SetConfig set config for all handlers

func UpgradeConnection

func UpgradeConnection(
	hub *WebSocketHub,
	handler *Handler,
	clientGuid string,
	clientAttributes ClientAttributes,
	w http.ResponseWriter,
	r *http.Request,
) error

func WelcomeMessage added in v0.0.12

func WelcomeMessage(welcomeMessageFunc func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, r *http.Request) ([]byte, error)) *func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, r *http.Request) ([]byte, error)

Types

type ClientAttributes

type ClientAttributes map[string]interface{}

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

type ClientMessage

type ClientMessage struct {
	Message []byte
	Client  ClientAttributes
}

type Config

type Config struct {
	CORS      *string
	CustomLog ulog.ULogger
}

func GetConfig

func GetConfig() Config

type Handler

type Handler struct {
	UhttpHandler     uhttp.Handler
	ClientAttributes *func(hub *WebSocketHub, r *http.Request) (ClientAttributes, error)
	WelcomeMessage   *func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, r *http.Request) ([]byte, error)
	OnConnect        *func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, r *http.Request)
	OnDisconnect     *func(hub *WebSocketHub, clientGuid string, clientAttributes ClientAttributes, err error)
	OnError          *func(err error)
}

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, messageHandler *chan ClientMessage, ctx context.Context) *WebSocketHub

func NewWebSocketHub

func NewWebSocketHub(u *uhttp.UHTTP, messagHandler *chan ClientMessage, ctx context.Context) *WebSocketHub

func (*WebSocketHub) Handle

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

func (*WebSocketHub) Run

func (h *WebSocketHub) Run()

func (*WebSocketHub) SendWithFilter

func (h *WebSocketHub) SendWithFilter(filterFunc func(attrs ClientAttributes) bool, message []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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