Пример #1
0
        public VirtualOfficeUser AddUser(string connectionId, string name, string icon)
        {
            lock (@lock)
            {
                var desk = _deskDispatcher.Dispatch(this, connectionId, name);

                if (desk == null)
                {
                    return(null);
                }

                var user = new VirtualOfficeUser
                {
                    ConnectionId = connectionId,
                    Name         = name,
                    Icon         = icon,
                    DeskId       = desk.Id
                };
                return(_users.TryAdd(connectionId, user) ? user : null);
            }
        }
Пример #2
0
        public VirtualOfficeUser AddUser(string connectionId, string name, string icon)
        {
            lock (@lock)
            {
                var desks = Desks.OrderBy(desk => desk.R);
                var desk  = desks.FirstOrDefault(d => !Users.Any(u => u.DeskId == d.Id))
                            ?? desks.FirstOrDefault();

                if (desk == null)
                {
                    return(null);
                }

                var user = new VirtualOfficeUser
                {
                    ConnectionId = connectionId,
                    Name         = name,
                    Icon         = icon,
                    DeskId       = desk.Id
                };
                return(_users.TryAdd(connectionId, user) ? user : null);
            }
        }