Documentation ¶
Index ¶
- Constants
- type APIConfig
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) ErrorCh() <-chan error
- func (c *Client) ReceiveCh() <-chan ClientMessage
- func (c *Client) Register(clientID string, authKey string) error
- func (c *Client) Send(msg ClientMessage) error
- func (c *Client) Unregister(clientID string) error
- type ClientConfig
- type ClientMessage
- type ClientOption
- type ClientReconnectCb
- type Config
- type DialContextFn
- type SecurityConfig
- type Service
- type StoreConfig
Constants ¶
View Source
const ( ClientMessageJoin = "join" ClientMessageLeave = "leave" ClientMessageRTC = "rtc" ClientMessageHello = "hello" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIConfig ¶
type APIConfig struct { HTTP api.Config `toml:"http"` Security SecurityConfig `toml:"security"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(cfg ClientConfig, opts ...ClientOption) (*Client, error)
func (*Client) ReceiveCh ¶
func (c *Client) ReceiveCh() <-chan ClientMessage
func (*Client) Send ¶
func (c *Client) Send(msg ClientMessage) error
func (*Client) Unregister ¶
type ClientConfig ¶
type ClientConfig struct { ClientID string AuthKey string URL string ReconnectInterval time.Duration // contains filtered or unexported fields }
func (*ClientConfig) Parse ¶
func (c *ClientConfig) Parse() error
type ClientMessage ¶
type ClientMessage struct { Type string `msgpack:"type"` Data interface{} `msgpack:"data,omitempty"` }
func NewClientMessage ¶
func NewClientMessage(msgType string, data interface{}) *ClientMessage
func (*ClientMessage) DecodeMsgpack ¶
func (cm *ClientMessage) DecodeMsgpack(dec *msgpack.Decoder) error
func (*ClientMessage) EncodeMsgpack ¶
func (cm *ClientMessage) EncodeMsgpack(enc *msgpack.Encoder) error
func (*ClientMessage) Pack ¶
func (cm *ClientMessage) Pack() ([]byte, error)
func (*ClientMessage) Unpack ¶
func (cm *ClientMessage) Unpack(data []byte) error
type ClientOption ¶
func WithClientReconnectCb ¶
func WithClientReconnectCb(cb ClientReconnectCb) ClientOption
WithClientReconnectCb lets the caller set an optional callback to be called prior to performing a WebSocket reconnection.
func WithDialFunc ¶ added in v0.5.0
func WithDialFunc(dialFn DialContextFn) ClientOption
WithDialFunc lets the caller set an optional dialing function to setup the HTTP/WebSocket connections used by the client.
type ClientReconnectCb ¶
type Config ¶
type Config struct { API APIConfig RTC rtc.ServerConfig Store StoreConfig Logger logger.Config }
func (*Config) SetDefaults ¶
func (c *Config) SetDefaults()
type DialContextFn ¶ added in v0.5.0
type SecurityConfig ¶
type SecurityConfig struct { // Whether or not to enable admin API access. EnableAdmin bool `toml:"enable_admin"` // The secret key used to authenticate admin requests. AdminSecretKey string `toml:"admin_secret_key"` // Whether or not to allow clients to self-register. AllowSelfRegistration bool `toml:"allow_self_registration"` }
func (SecurityConfig) IsValid ¶
func (c SecurityConfig) IsValid() error
type StoreConfig ¶
type StoreConfig struct {
DataSource string `toml:"data_source"`
}
func (StoreConfig) IsValid ¶
func (c StoreConfig) IsValid() error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.