websocket

package
v0.0.0-...-6b52c20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2017 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastMessage

func BroadcastMessage(msg string)

func HandleWebSocketCommand

func HandleWebSocketCommand(cmd string, handler func(c *WebsocketConnection, array []string))

func InitWebSocket

func InitWebSocket(env *env.Env)

func ServeWs

func ServeWs(w http.ResponseWriter, r *http.Request)

serveWs handles websocket requests from the peer.

Types

type Command

type Command struct {
}

func (Command) AddSeed

func (this Command) AddSeed(c *WebsocketConnection, a []string)

func (Command) Dispatch

func (this Command) Dispatch(c *WebsocketConnection, a []string)

func (Command) GetTask

func (this Command) GetTask(c *WebsocketConnection, a []string)

func (Command) Help

func (this Command) Help(c *WebsocketConnection, a []string)

func (Command) UpdateLogLevel

func (this Command) UpdateLogLevel(c *WebsocketConnection, a []string)

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

hub maintains the set of active connections and broadcasts messages to the connections.

func (*Hub) RunHub

func (h *Hub) RunHub()

type MsgType

type MsgType string
const (
	PrivateMessage MsgType = "PRIVATE"
	PublicMessage  MsgType = "PUBLIC"
	ConfigMessage  MsgType = "CONFIG"
)

type WebsocketConnection

type WebsocketConnection struct {
	// contains filtered or unexported fields
}

connection is an middleman between the websocket connection and the hub.

func (*WebsocketConnection) Broadcast

func (c *WebsocketConnection) Broadcast(msg string)

func (*WebsocketConnection) WriteMessage

func (c *WebsocketConnection) WriteMessage(t MsgType, msg string) error

the right way to write message, don't call c.write directly

func (*WebsocketConnection) WritePrivateMessage

func (c *WebsocketConnection) WritePrivateMessage(msg string) error

type WebsocketHandlerFunc

type WebsocketHandlerFunc func(c *WebsocketConnection, array []string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL