Exemplo n.º 1
0
        public Task ChangeImage(string email)
        {
            UserData user;

            if (_users.TryGetValue(Context.ConnectionId, out user))
            {
                user.Image = GravatarHelpers.GetImage(email);
                return(Clients.All.ImageChangedNotification(user));
            }
            return(null);
        }
Exemplo n.º 2
0
        public override Task OnConnected()
        {
            Interlocked.Increment(ref _usersCount);
            var user = new UserData()
            {
                Id          = Context.ConnectionId,
                Active      = true,
                Name        = "user" + _usersCount,
                Image       = GravatarHelpers.GetImage(null),
                ConnectedAt = DateTime.Now
            };

            _users[Context.ConnectionId] = user;

            var notifyAll    = (Task)Clients.All.NewUserNotification(user);
            var sendAllUsers = (Task)Clients.Caller.Welcome(user.Name, _users.Values.ToArray());

            return(notifyAll.ContinueWith(_ => sendAllUsers));
        }