示例#1
0
        public Task <UserRegistery> RegisterUserAsync(string username)
        {
            if (Users.Any(user => user.Username.Equals(username, StringComparison.CurrentCulture)))
            {
                return(Task.FromResult((UserRegistery)null));
            }
            var currentUser = new UserRegistery
            {
                Username           = username,
                UserToken          = Guid.NewGuid(),
                LastConnectionDate = DateTime.UtcNow
            };

            Users.Add(currentUser);

            return(Task.FromResult(currentUser));
        }
示例#2
0
        public async Task <bool> UpdateRoomRegisteryAsync(UserRegistery user, RoomRegistry roomData)
        {
            if (!Users.Any(r => r.Username.Equals(user.Username, StringComparison.Ordinal) &&
                           r.UserToken == user.UserToken))
            {
                return(false);
            }

            if (!roomData.CreatedBy.Equals(user.Username))
            {
                return(false);
            }

            await GrainFactory.GetGrain <IRoomGrain>(roomData.RoomName).SetupRoomAsync(roomData);

            return(true);
        }
示例#3
0
        public Task <bool> DeleteRoomAsync(UserRegistery user, string roomName)
        {
            if (!Users.Any(r => r.Username.Equals(user.Username, StringComparison.Ordinal) &&
                           r.UserToken == user.UserToken))
            {
                return(Task.FromResult(false));
            }

            var room = Rooms.SingleOrDefault(r => r.RoomName.Equals(roomName, StringComparison.Ordinal));

            if (room == null)
            {
                return(Task.FromResult(false));
            }

            room.IsDeleted         = true;
            room.IsPubliclyVisible = false;

            return(Task.FromResult(true));
        }
示例#4
0
 public Task MessageAsync(UserRegistery user, string message)
 {
 }