Documentation
¶
Index ¶
- Variables
- type ClientAttributes
- func (c *ClientAttributes) GetBool(key string) (bool, error)
- func (c *ClientAttributes) GetString(key string) (string, error)
- func (c *ClientAttributes) HasMatch(key string, value string) bool
- func (c *ClientAttributes) IsFlagSet(key string) bool
- func (c *ClientAttributes) SetBool(key string, value bool) *ClientAttributes
- func (c *ClientAttributes) SetString(key string, value string) *ClientAttributes
- func (c *ClientAttributes) String() string
- type ClientMessage
- type Handler
- type HandlerOption
- func WithClientAttributes(f func(hub WebSocketHub, r *http.Request) (*ClientAttributes, error)) HandlerOption
- func WithOnConnect(...) HandlerOption
- func WithOnError(...) HandlerOption
- func WithOnIncomingMessage(...) HandlerOption
- func WithUhttpHandler(h uhttp.Handler) HandlerOption
- func WithWelcomeMessages(...) HandlerOption
- type SendOption
- func WithClientFilter(clientGUID string) SendOption
- func WithFilterFn(fn func(clientGUID string, attrs *ClientAttributes) bool) SendOption
- func WithFlagFilter(flag string) SendOption
- func WithMatchFilter(key string, value string) SendOption
- func WithMessage(message []byte) SendOption
- func WithMessageFn(fn func() ([]byte, error)) SendOption
- type WebSocketClient
- type WebSocketClientMock
- func (c *WebSocketClientMock) Attributes() *ClientAttributes
- func (c *WebSocketClientMock) Cancel()
- func (c *WebSocketClientMock) ClientGUID() string
- func (c *WebSocketClientMock) Ctx() context.Context
- func (c *WebSocketClientMock) Handler() Handler
- func (c *WebSocketClientMock) Request() *http.Request
- func (c *WebSocketClientMock) Run(ctx context.Context)
- func (c *WebSocketClientMock) SendChan() chan []byte
- type WebSocketHub
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 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 SendOption ¶ added in v1.0.12
type SendOption func(*sendOptions)
func WithClientFilter ¶ added in v1.0.15
func WithClientFilter(clientGUID string) SendOption
func WithFilterFn ¶ added in v1.0.12
func WithFilterFn(fn func(clientGUID string, attrs *ClientAttributes) bool) SendOption
Specify the filter function to be called for each client
func WithFlagFilter ¶ added in v1.0.15
func WithFlagFilter(flag string) SendOption
func WithMatchFilter ¶ added in v1.0.15
func WithMatchFilter(key string, value string) SendOption
func WithMessage ¶ added in v1.0.12
func WithMessage(message []byte) SendOption
Specify the message to send
func WithMessageFn ¶ added in v1.0.12
func WithMessageFn(fn func() ([]byte, error)) SendOption
Specify the function to be called for generating the massage if the filter function returns true
type WebSocketClient ¶
type WebSocketClientMock ¶ added in v1.0.15
type WebSocketClientMock struct {
// contains filtered or unexported fields
}
func NewWebSocketClientMock ¶ added in v1.0.15
func NewWebSocketClientMock(t *testing.T, ctx context.Context, guid string, attrs *ClientAttributes) *WebSocketClientMock
func (*WebSocketClientMock) Attributes ¶ added in v1.0.15
func (c *WebSocketClientMock) Attributes() *ClientAttributes
func (*WebSocketClientMock) Cancel ¶ added in v1.0.15
func (c *WebSocketClientMock) Cancel()
func (*WebSocketClientMock) ClientGUID ¶ added in v1.0.15
func (c *WebSocketClientMock) ClientGUID() string
func (*WebSocketClientMock) Ctx ¶ added in v1.0.15
func (c *WebSocketClientMock) Ctx() context.Context
func (*WebSocketClientMock) Handler ¶ added in v1.0.15
func (c *WebSocketClientMock) Handler() Handler
func (*WebSocketClientMock) Request ¶ added in v1.0.15
func (c *WebSocketClientMock) Request() *http.Request
func (*WebSocketClientMock) Run ¶ added in v1.0.15
func (c *WebSocketClientMock) Run(ctx context.Context)
func (*WebSocketClientMock) SendChan ¶ added in v1.0.15
func (c *WebSocketClientMock) SendChan() chan []byte
type WebSocketHub ¶
type WebSocketHub interface { Send(opts ...SendOption) Run() Handle(pattern string, handler Handler) CountClientsWithFilter(filterFunc func(clientGUID string, attrs *ClientAttributes) bool) int }
func NewWebSocketHub ¶
Click to show internal directories.
Click to hide internal directories.