uwebsocket

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnConnect

func OnConnect(onConnectFunc func(r *http.Request)) *func(r *http.Request)

func SetConfig

func SetConfig(_config Config)

SetConfig set config for all handlers

func UpgradeConnection

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

Types

type ClientAttributes

type ClientAttributes interface{}

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 ClientAttributes
	OnConnect        *func(r *http.Request)
}

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(messagHandler *chan ClientMessage) *WebSocketHub

func NewWebSocketHub

func NewWebSocketHub(messagHandler *chan ClientMessage) *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

Jump to

Keyboard shortcuts

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