github.com/philippseith/signalr@v0.6.3/hubclients.go (about) 1 package signalr 2 3 // HubClients gives the hub access to various client groups 4 // All() gets a ClientProxy that can be used to invoke methods on all clients connected to the hub 5 // Caller() gets a ClientProxy that can be used to invoke methods of the current calling client 6 // Client() gets a ClientProxy that can be used to invoke methods on the specified client connection 7 // Group() gets a ClientProxy that can be used to invoke methods on all connections in the specified group 8 type HubClients interface { 9 All() ClientProxy 10 Caller() ClientProxy 11 Client(connectionID string) ClientProxy 12 Group(groupName string) ClientProxy 13 } 14 15 type defaultHubClients struct { 16 lifetimeManager HubLifetimeManager 17 allCache allClientProxy 18 } 19 20 func (c *defaultHubClients) All() ClientProxy { 21 return &c.allCache 22 } 23 24 func (c *defaultHubClients) Client(connectionID string) ClientProxy { 25 return &singleClientProxy{connectionID: connectionID, lifetimeManager: c.lifetimeManager} 26 } 27 28 func (c *defaultHubClients) Group(groupName string) ClientProxy { 29 return &groupClientProxy{groupName: groupName, lifetimeManager: c.lifetimeManager} 30 } 31 32 // Caller is only implemented to fulfill the HubClients interface, so the servers defaultHubClients interface can be 33 // used for implementing Server.HubClients. 34 func (c *defaultHubClients) Caller() ClientProxy { 35 return nil 36 } 37 38 type callerHubClients struct { 39 defaultHubClients *defaultHubClients 40 connectionID string 41 } 42 43 func (c *callerHubClients) All() ClientProxy { 44 return c.defaultHubClients.All() 45 } 46 47 func (c *callerHubClients) Caller() ClientProxy { 48 return c.defaultHubClients.Client(c.connectionID) 49 } 50 51 func (c *callerHubClients) Client(connectionID string) ClientProxy { 52 return c.defaultHubClients.Client(connectionID) 53 } 54 55 func (c *callerHubClients) Group(groupName string) ClientProxy { 56 return c.defaultHubClients.Group(groupName) 57 }