-
Notifications
You must be signed in to change notification settings - Fork 41
/
hubclients.go
57 lines (46 loc) · 1.82 KB
/
hubclients.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package signalr
// HubClients gives the hub access to various client groups
// All() gets a ClientProxy that can be used to invoke methods on all clients connected to the hub
// Caller() gets a ClientProxy that can be used to invoke methods of the current calling client
// Client() gets a ClientProxy that can be used to invoke methods on the specified client connection
// Group() gets a ClientProxy that can be used to invoke methods on all connections in the specified group
type HubClients interface {
All() ClientProxy
Caller() ClientProxy
Client(connectionID string) ClientProxy
Group(groupName string) ClientProxy
}
type defaultHubClients struct {
lifetimeManager HubLifetimeManager
allCache allClientProxy
}
func (c *defaultHubClients) All() ClientProxy {
return &c.allCache
}
func (c *defaultHubClients) Client(connectionID string) ClientProxy {
return &singleClientProxy{connectionID: connectionID, lifetimeManager: c.lifetimeManager}
}
func (c *defaultHubClients) Group(groupName string) ClientProxy {
return &groupClientProxy{groupName: groupName, lifetimeManager: c.lifetimeManager}
}
// Caller is only implemented to fulfill the HubClients interface, so the servers defaultHubClients interface can be
// used for implementing Server.HubClients.
func (c *defaultHubClients) Caller() ClientProxy {
return nil
}
type callerHubClients struct {
defaultHubClients *defaultHubClients
connectionID string
}
func (c *callerHubClients) All() ClientProxy {
return c.defaultHubClients.All()
}
func (c *callerHubClients) Caller() ClientProxy {
return c.defaultHubClients.Client(c.connectionID)
}
func (c *callerHubClients) Client(connectionID string) ClientProxy {
return c.defaultHubClients.Client(connectionID)
}
func (c *callerHubClients) Group(groupName string) ClientProxy {
return c.defaultHubClients.Group(groupName)
}