forked from simon-whitehead/relayr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
relay.go
32 lines (27 loc) · 1.01 KB
/
relay.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
30
31
32
package relayr
import "reflect"
// Relay encapsulates a connection with a client
// during an interaction with the server. It provides methods
// for interacting with clients and groups.
type Relay struct {
Name string // The name of the relay it is associated with
ConnectionID string // The connectionID of the client that this Relay interacts with
Clients *ClientOperations // An abstraction over clients currently connected to this Relay
methods []string
t reflect.Type
exchange *Exchange
}
// Call will execute a function on another server-side Relay,
// passing along the details of the currently connected client.
func (r *Relay) Call(fn string, args ...interface{}) {
r.exchange.callRelayMethod(r, fn, args...)
}
// Groups returns a GroupOperations object, which offers helper
// methods for communicating with and grouping clients.
func (r *Relay) Groups(group string) *GroupOperations {
return &GroupOperations{
group: group,
e: r.exchange,
relay: r,
}
}