Ejemplo n.º 1
0
        public override Task OnConnectedAsync()
        {
            string userId = Context.GetHttpContext().Request.Query["userId"].ToString();

            //add the connection to the group that corresponds to the user id
            Groups.AddToGroupAsync(Context.ConnectionId, userId);
            SignalRConnectionToGroupsMap.TryAddGroup(Context.ConnectionId, userId);
            return(base.OnConnectedAsync());
        }
Ejemplo n.º 2
0
        public Task Subscribe(String id)
        {
            List <String> groups;
            var           success = SignalRConnectionToGroupsMap.TryRemoveConnection(Context.ConnectionId, out groups);

            if (groups != null)
            {
                foreach (var group in groups)
                {
                    Groups.Remove(Context.ConnectionId, group);
                }
            }

            SignalRConnectionToGroupsMap.TryAddGroup(Context.ConnectionId, id);
            return(Groups.Add(Context.ConnectionId, id));
        }