forked from simon-whitehead/relayr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroupOps.go
29 lines (25 loc) · 960 Bytes
/
groupOps.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package relayr
// GroupOperations provides helper methods for communicating
// with clients in groups. Clients must be added to a group
// to be considered a member of a group.
type GroupOperations struct {
relay *Relay
group string
e *Exchange
}
// Add adds a client to a group via its ConnectionID. It
// is a member of the group for the remainder of its
// connection. At that point, the client must re-negotiate
// its place within the group to be considered a member of it.
func (g *GroupOperations) Add(connectionID string) {
g.e.addToGroup(g.group, connectionID)
}
// Remove removes a client from a group via its ConnectionID.
func (g *GroupOperations) Remove(connectionID string) {
g.e.removeFromGroupByID(g.group, connectionID)
}
// Call invokes a client-side method across a Group of clients,
// passing args to them.
func (g *GroupOperations) Call(fn string, args ...interface{}) {
g.e.callGroupMethod(g.relay, g.group, fn, args...)
}