Documentation ¶
Index ¶
- Variables
- type Auth
- type BatchData
- type Client
- func (c *Client) AddChannel(s string)
- func (c *Client) Close()
- func (c *Client) GetAuth() Auth
- func (c *Client) Listen(re ReceiveMsgHandler)
- func (c *Client) Off(event string)
- func (c *Client) On(event string, h EventHandler)
- func (c *Client) Send(data []byte)
- func (c *Client) SetChannels(s []string)
- func (c *Client) SocketId() string
- func (c *Client) Trigger(event string, p *Payload) (err error)
- type EventHandler
- type Hub
- type Payload
- type ReceiveMsgHandler
- type Sender
- func (s *Sender) AddChannel(channelPrefix, appKey string, uid string, channel string) (val int, err error)
- func (s *Sender) GetChannels(channelPrefix string, appKey string, pattern string) (channels []string, err error)
- func (s *Sender) GetOnline(channelPrefix string, appKey string) (online []string, err error)
- func (s *Sender) GetOnlineByChannel(channelPrefix string, appKey string, channel string) (online []string, err error)
- func (s *Sender) Push(channelPrefix, appKey string, event string, data []byte) (val int, err error)
- func (s *Sender) PushBatch(channelPrefix, appKey string, data []BatchData)
- func (s *Sender) PushToSid(channelPrefix, appKey string, uid string, data interface{}) (val int, err error)
- func (s *Sender) PushToUid(channelPrefix, appKey string, uid string, data interface{}) (val int, err error)
- func (s *Sender) ReloadChannel(channelPrefix, appKey string, uid string, channels []string) (val int, err error)
- type Statistic
- type User
- type WebsocketOptional
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //DefaultWebsocketOptional default config DefaultWebsocketOptional = WebsocketOptional{ ScanInterval: 30 * time.Second, WriteWait: 10 * time.Second, PongWait: 60 * time.Second, PingPeriod: (60 * time.Second * 9) / 10, MaxMessageSize: 512, Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, }, } )
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client gorilla websocket wrap struct
func (*Client) AddChannel ¶
func (*Client) Listen ¶
func (c *Client) Listen(re ReceiveMsgHandler)
Listen client client start listen it's block method
func (*Client) SetChannels ¶
type EventHandler ¶
EventHandler event handler
type Hub ¶
type Hub struct { ChannelPrefix string Config WebsocketOptional // contains filtered or unexported fields }
Hub client hub
func (*Hub) CountOnlineUsers ¶
CountOnlineUsers return online user total
type Payload ¶
type Payload struct { Len int Data []byte PrepareMessage *websocket.PreparedMessage IsPrepare bool Event string }
Payload reciev from redis
type ReceiveMsgHandler ¶
ReceiveMsgHandler client receive msg
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender struct
func (*Sender) AddChannel ¶
func (s *Sender) AddChannel(channelPrefix, appKey string, uid string, channel string) (val int, err error)
AddChannel append channel to user channel list
func (*Sender) GetChannels ¶
func (s *Sender) GetChannels(channelPrefix string, appKey string, pattern string) (channels []string, err error)
GetChannels get all sub channels
func (*Sender) GetOnlineByChannel ¶
func (s *Sender) GetOnlineByChannel(channelPrefix string, appKey string, channel string) (online []string, err error)
GetOnlineByChannel get all online user by channel
func (*Sender) PushToSid ¶
func (s *Sender) PushToSid(channelPrefix, appKey string, uid string, data interface{}) (val int, err error)
PushToSid push to user socket id
Click to show internal directories.
Click to hide internal directories.