Esempio n. 1
0
        public async Task GetClientsToGroupAsync(string groupName)
        {
            Group group = InMemoryDB.GetGroup(groupName);

            await Clients.Caller.ClientsDataAsync(
                groupName == GroupName
                ?InMemoryDB.GetAllClient()
                    : group.Clients);
        }
Esempio n. 2
0
        public async Task AddClientToGroupsAsync(IEnumerable <string> groupNames)
        {
            Client client = InMemoryDB.GetClientByConnectionId(Context.ConnectionId);

            foreach (var groupName in groupNames)
            {
                Group group = InMemoryDB.GetGroup(groupName);

                var result = group.Clients.Any(i => i.ConnectionId == Context.ConnectionId);
                if (result)
                {
                    continue;
                }
                @group.Clients.Add(client);

                await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
            }
        }