Documentation ¶
Index ¶
- func FormatCloseMessage(closeCode int, text string) []byte
- type Notifier
- func (n *Notifier) Broadcast(msg []byte) error
- func (n *Notifier) Close() error
- func (n *Notifier) CloseGroupWithMsg(groupID string, msg []byte) error
- func (n *Notifier) CloseWithMsg(msg []byte) error
- func (n *Notifier) GroupBroadcast(msg []byte, groupID string) error
- func (n *Notifier) GroupLen(groupID string) int
- func (n *Notifier) HandleRequest(w http.ResponseWriter, r *http.Request) error
- func (n *Notifier) HandleRequestWithKeys(w http.ResponseWriter, r *http.Request, keys map[string]interface{}) error
- func (n *Notifier) IsClosed() bool
- func (n *Notifier) Len() int
- func (n *Notifier) Notify(groupID string, f workerFunc, timeout time.Duration) error
- func (n *Notifier) ReleaseWorker(groupID string)
- func (n *Notifier) ShowWorkers() []string
- type NotifyMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCloseMessage ¶
FormatCloseMessage formats closeCode and text as a WebSocket close message.
Types ¶
type Notifier ¶
type Notifier struct { SessionManager *sessionmanager.SessionManager Melody *melody.Melody // contains filtered or unexported fields }
Notifier wrapped websocket operation for notifier
func (*Notifier) CloseGroupWithMsg ¶
CloseGroupWithMsg close all websocket connections of a group with messages. Use the FormatCloseMessage function to format a proper close message payload.
func (*Notifier) CloseWithMsg ¶
CloseWithMsg close all websocket connections with messages. Use the FormatCloseMessage function to format a proper close message payload.
func (*Notifier) GroupBroadcast ¶
GroupBroadcast broadcast message to a group
func (*Notifier) HandleRequest ¶
HandleRequest upgrades http requests to websocket connections and dispatches them to be handled by the melody instance.
func (*Notifier) HandleRequestWithKeys ¶
func (n *Notifier) HandleRequestWithKeys(w http.ResponseWriter, r *http.Request, keys map[string]interface{}) error
HandleRequestWithKeys does the same as HandleRequest but populates session.Keys with keys.
func (*Notifier) ReleaseWorker ¶
ReleaseWorker release worker for a group, usually called from a workerFunc when goroutine exited
func (*Notifier) ShowWorkers ¶
ShowWorkers shows all workers
type NotifyMessage ¶
type NotifyMessage struct { Type string `json:"type"` Code int32 `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
NotifyMessage is common struct for notifier