Documentation
¶
Index ¶
- Variables
- func ClientAttributesFunc(...) *func(hub *WebSocketHub, r *http.Request) (*ClientAttributes, error)
- func OnConnect(...) ...
- func OnDisconnect(...) ...
- func OnError(...) ...
- func SetConfig(_config Config)
- func UpgradeConnection(hub *WebSocketHub, handler *Handler, clientGuid string, ...) error
- func WelcomeMessage(...) ...
- 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 Config
- type Handler
- type WebSocketClient
- type WebSocketHub
- func (h *WebSocketHub) Handle(pattern string, handler *Handler)
- func (h *WebSocketHub) Run()
- func (h *WebSocketHub) SendToAllWithFlagSync(flag string, message []byte, ctx context.Context) error
- func (h *WebSocketHub) SendToAllWithMatchSync(key string, value string, message []byte, ctx context.Context) error
- func (h *WebSocketHub) SendToClientSync(clientGUID string, message []byte, ctx context.Context) error
- func (h *WebSocketHub) SendWithFilterSync(filterFunc func(clientGUID string, attrs *ClientAttributes) bool, ...) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
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, r *http.Request, err error)) *func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, err error)
func OnError ¶ added in v0.0.5
func OnError(onErrorFunc func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, err error)) *func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, err error)
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 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 {
Message []byte
ClientGUID string
ClientAttributes *ClientAttributes
}
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, r *http.Request, err error)
OnError *func(hub *WebSocketHub, clientGuid string, clientAttributes *ClientAttributes, r *http.Request, 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) SendToAllWithFlagSync ¶ added in v0.0.13
func (*WebSocketHub) SendToAllWithMatchSync ¶ added in v0.0.13
func (*WebSocketHub) SendToClientSync ¶ added in v0.0.13
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
Source Files
¶
Click to show internal directories.
Click to hide internal directories.