ws

package
v0.0.0-...-8419220 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upgrader = websocket.Upgrader{
	ReadBufferSize:  1024,
	WriteBufferSize: 1024,
}

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// The websocket connection id.
	ID string

	// The websocket connection.
	Ws *websocket.Conn

	// The websocket filter.
	Filter *model.Filter

	// Buffered channel of outbound messages.
	Send chan *model.Log
}

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

func (*Connection) Write

func (c *Connection) Write(mt int, payload []byte) error

write writes a message with the given message type and payload.

func (*Connection) WritePump

func (c *Connection) WritePump()

writePump pumps messages from the hub to the websocket connection.

type Hub

type Hub struct {
	// Registered connections.
	Connections map[*Connection]bool

	// Inbound messages from the connections.
	Broadcast chan *model.Log

	// Register requests from the connections.
	Register chan *Connection

	// Unregister requests from connections.
	Unregister chan *Connection

	// RegisterFilter registers filter for specified connection.
	RegisterFilter chan *model.Filter

	// UnregisterFilter unregisters filter for specified connection.
	UnregisterFilter chan string
}

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

func NewHub

func NewHub() *Hub

func (*Hub) Run

func (h *Hub) Run()

Jump to

Keyboard shortcuts

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