Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Read() ([]byte, error)
- func (c *Client) ReadJSON(bean interface{}) error
- func (c *Client) ReadString() (string, error)
- func (c *Client) ReadTimeout(timeout time.Duration) ([]byte, error)
- func (c *Client) Start()
- func (c *Client) Write(msg []byte)
- func (c *Client) WriteJSON(msg interface{})
- func (c *Client) WriteString(msg string)
- type WsHub
Constants ¶
This section is empty.
Variables ¶
View Source
var (
TimeoutErr = errors.New("Timeout hit before messaged recieved") //Is it best to use an error for the timeout
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ReadString ¶
func (*Client) ReadTimeout ¶
Read a message, but give up after a given timeout returns nil if the timeout is hit
func (*Client) Start ¶
func (c *Client) Start()
Starts the client listening handler to write messages to
func (*Client) WriteJSON ¶
func (c *Client) WriteJSON(msg interface{})
Write a JSON message to the client
func (*Client) WriteString ¶
Write a string message to the client
type WsHub ¶
type WsHub struct {
// contains filtered or unexported fields
}
Central communitaion struct
func (*WsHub) BroadcastJSON ¶
func (*WsHub) RegisterClient ¶
Register a given client object
func (*WsHub) Run ¶
func (h *WsHub) Run()
Run the hub (most likely in its own goroutine) Handles all communitaion between connected clients
func (*WsHub) UnregisterClient ¶
Unregister a given client
Click to show internal directories.
Click to hide internal directories.