Documentation ¶
Index ¶
Constants ¶
View Source
const ( ConnectionTypePub = "Pub" ConnectionTypeSub = "Sub" ConnectionTypePubSub = "PubSub" )
Variables ¶
View Source
var DefaultHub = Hub{ Register: make(chan *Connection), Unregister: make(chan *Connection), Data: make(chan *Message), // contains filtered or unexported fields }
The default Hub instance used all around this code
Functions ¶
func PubSubWebHandler ¶
Handle connection from clients for both publications and subscriptions
func PubWebHandler ¶
Handle connection from clients for publications only
func SubWebHandler ¶
Handle connection from clients for subscriptions only
Types ¶
type Connection ¶
type Connection struct { ID string WS *websocket.Conn Type ConnectionType Send chan *Message Created time.Time Updated time.Time }
Connection data structure
type ConnectionType ¶
type ConnectionType string
type Hub ¶
type Hub struct { // Unique name for this hub ID string // Register requests from the connections Register chan *Connection // Unregister requests from connections Unregister chan *Connection // Uplink connection settings Uplink *Connection UplinkType ConnectionType // Data handling channel Data chan *Message // contains filtered or unexported fields }
The communication hub between the active connections
func (*Hub) RouteMessage ¶
Route a message to subscribers
func (*Hub) SetupUplink ¶
Establish uplink connection toa given WS url
Click to show internal directories.
Click to hide internal directories.