Documentation
¶
Index ¶
- type Client
- type Hub
- func (h *Hub) EvaluatePluginFilterEvent(event *types.Event, pluginFilter string) bool
- func (h *Hub) GetHistory() []*types.Event
- func (h *Hub) GetInfo() *types.Event
- func (h *Hub) NoClients() int
- func (h *Hub) Run()
- func (h *Hub) RunPluginFilterEvent(event *types.Event, prog *vm.Program) bool
- func (h *Hub) SendInfo(event *types.Event)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Buffered channel of outbound messages.
Send chan []byte
SendEvents chan []*types.Event
Language string
PluginChan chan []*types.Event
// WaitGroup which keeps track of running read/write loops and write access to Send. If the WaitGroup is done,
// it is safe to close all channels (all loops are done and there are no more write operations on the channels)
sync.WaitGroup
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub.
func (*Client) PluginLoop ¶
func (c *Client) PluginLoop()
A per-client plugin loop. Reads the PluginChan and calls per-client plugins. Will be exited when the PluginChan is closed.
func (*Client) ReadLoop ¶
func (c *Client) ReadLoop()
ReadLoop pumps messages from the websocket connection to the hub.
The application runs ReadLoop in a per-connection goroutine. The application ensures that there is at most one reader on a connection by executing all reads from this goroutine.
func (*Client) RunFilterEvent ¶
func (*Client) SendHistory ¶
func (*Client) WriteLoop ¶
func (c *Client) WriteLoop()
WriteLoop pumps messages from the hub to the websocket connection.
A goroutine running WriteLoop is started for each connection. The application ensures that there is at most one writer to a connection by executing all writes from this goroutine.
type Hub ¶
type Hub struct {
// there is one hub per room
*types.Room
// Broadcast events to all clients.
BroadcastEvents chan []*types.Event
// Register a new client to the hub.
Register chan *Client
// Unregister a client from the hub.
Unregister chan *Client
// keep the chat history in a ring buffer
EventHistory chan []*types.Event
// global configuration
Cfg *config.Config
// persistence
Persister persistence.Persister
// mutex for manipulating the clients
sync.RWMutex
// contains filtered or unexported fields
}
func NewHub ¶
func NewHub(room *types.Room, cfg *config.Config, persister persistence.Persister, pluginMap map[string]plugins.PluginSpec) *Hub
func (*Hub) EvaluatePluginFilterEvent ¶
func (*Hub) GetHistory ¶
func (*Hub) Run ¶
func (h *Hub) Run()
Run is the main hub event loop handling register, unregister and broadcast events.