Documentation
¶
Index ¶
- func BroadcastMessage(msg string)
- func HandleWebSocketCommand(cmd string, handler func(c *WebsocketConnection, array []string))
- func InitWebSocket(env *env.Env)
- func ServeWs(w http.ResponseWriter, r *http.Request)
- type Command
- func (command Command) AddSeed(c *WebsocketConnection, a []string)
- func (command Command) Dispatch(c *WebsocketConnection, a []string)
- func (command Command) GetTask(c *WebsocketConnection, a []string)
- func (command Command) Help(c *WebsocketConnection, a []string)
- func (command Command) UpdateLogLevel(c *WebsocketConnection, a []string)
- type Hub
- type MsgType
- type WebsocketConnection
- type WebsocketHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastMessage ¶
func BroadcastMessage(msg string)
BroadcastMessage send broadcast message to channel and record stats
func HandleWebSocketCommand ¶
func HandleWebSocketCommand(cmd string, handler func(c *WebsocketConnection, array []string))
HandleWebSocketCommand used to register command and handler
Types ¶
type Command ¶
type Command struct {
}
Command struct forms different command
func (Command) AddSeed ¶
func (command Command) AddSeed(c *WebsocketConnection, a []string)
AddSeed handle task creation by send a seed, eg: SEED http://elastic.co
func (Command) Dispatch ¶
func (command Command) Dispatch(c *WebsocketConnection, a []string)
Dispatch just send a dispatch signal to dispatch service
func (Command) GetTask ¶
func (command Command) GetTask(c *WebsocketConnection, a []string)
GetTask return task information by send task_id, or task field and value, eg: GET_TASK host elasticsearch.cn GET_TASK 596
func (Command) Help ¶
func (command Command) Help(c *WebsocketConnection, a []string)
Help command returns command help information
func (Command) UpdateLogLevel ¶
func (command Command) UpdateLogLevel(c *WebsocketConnection, a []string)
UpdateLogLevel update the logging level, usually used for debug
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub maintains the set of active connections and broadcasts messages to the connections.
type WebsocketConnection ¶
type WebsocketConnection struct {
// contains filtered or unexported fields
}
WebsocketConnection is an middleman between the websocket connection and the hub.
func (*WebsocketConnection) Broadcast ¶
func (c *WebsocketConnection) Broadcast(msg string)
Broadcast public message to all channels
func (*WebsocketConnection) WriteMessage ¶
func (c *WebsocketConnection) WriteMessage(t MsgType, msg string) error
WriteMessage will use the right way to write message, don't call c.write directly
func (*WebsocketConnection) WritePrivateMessage ¶
func (c *WebsocketConnection) WritePrivateMessage(msg string) error
WritePrivateMessage will send msg to channel
type WebsocketHandlerFunc ¶
type WebsocketHandlerFunc func(c *WebsocketConnection, array []string)
WebsocketHandlerFunc define the func to handle websocket