Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LogLevel string = "DEBUG"
LogLevel is the default logging level
Functions ¶
This section is empty.
Types ¶
type ActionMessage ¶
type ActionMessage struct { Action string `json:"action"` Payload interface{} `json:"payload"` }
ActionMessage is the message from the network
type Broker ¶
type Broker struct {
Hub
}
Broker is the application structure
func NewBroker ¶
func NewBroker(origins []string, opts ...BrokerOption) *Broker
NewBroker is a Broker constructor which instantiates the Hub.
type BrokerOption ¶
type BrokerOption func(*Broker)
func WithNotifier ¶
func WithNotifier(n Notifier) BrokerOption
type Client ¶
Client represents a single connection from a user.
func (*Client) ClearTopics ¶
func (c *Client) ClearTopics()
RemoveTopic removes topics from a client and the client from hub's topic map
func (*Client) SubscribeMultiple ¶
SubscribeMultiple subscribes the client to multiple topics.
type ConnMessage ¶
type Hub ¶
type Hub struct { // protects connections sync.Mutex OnSubscribe func(*Subscription) // contains filtered or unexported fields }
Hub contains the active clients with thread-safe connection management, handles subscriptions and broadcasts messages to the clients.
func NewHub ¶
NewHub Instantiates the Hub. Adds the factory design pattern as a websocket HTTP connection upgrader. Creates the broker's logger
func (*Hub) Publish ¶
func (h *Hub) Publish(m PublishMessage)
Publish sends Mailmessage m to the hub's emitter.
type MailMessage ¶
type Notifier ¶
type Notifier interface {
Notify(s string)
}
Notifier is used to track hub channel actions. This is mainly used for testing in hub_test.go.
type PublishMessage ¶
PublishMessage is the structure used for publishing message.
type Subscription ¶
Subscription represents a 1:1 relationship between topic and client.
type SubscriptionsMessage ¶
type SubscriptionsMessage struct {
Topics []string `json:"payload"`
}
SubscriptionsMessage is the structure used for subscriptions.