示例#1
0
        public override async Task OnConnectedAsync()
        {
            string callersUserName = await _userService.GetUserNameById(Context.User.Identity.Name);

            string connectionId = Context.ConnectionId;

            Dictionary <string, object> ids = _memoryAccess.GetUserConnectionIdList();

            ids.Add(callersUserName, connectionId);

            _memoryAccess.SetConnectionIdList(ids);
        }
        private string GetConnectionId(string name)
        {
            Dictionary <string, object> ids = _cache.GetUserConnectionIdList();

            return(ids[name].ToString());
        }