Beispiel #1
0
        public async Task MigrateClientQueue(string sessionId, string queue)
        {
            if (SessionHandler.IsValidSession(sessionId))
            {
                QueueModel myQueue        = SessionHandler.GetQueue(sessionId);
                string[]   charDelimiters = new string[] { "\",\"", ",[\"", "\"],", "],[" };
                queue = queue.Replace("[[", "");
                queue = queue.Replace("]]", "");
                string[] values = queue.Split(charDelimiters, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < values.Length; i += 8)
                {
                    VideoModel     video     = new VideoModel(values[i + 1], values[i + 2], values[i + 3], values[i + 4], values[i + 5], values[i + 6]);
                    QueueItemModel queueItem = new QueueItemModel(myQueue.NextId(), video, int.Parse(values[i + 7]));
                    myQueue.Queue.Add(queueItem);
                }
                await Clients.Caller.SendAsync("QueueMigrated");
            }
        }
Beispiel #2
0
        public async Task AddToQueue(string sessionId, string userId, string[] data, bool isPlaylist)
        {
            if (SessionHandler.GetUsersSession(userId) == sessionId)
            {
                if (!SessionHandler.GetPermissions(sessionId).CanAddPlaylist&& isPlaylist && !SessionHandler.IsHostUser(sessionId, userId))
                {
                    return;
                }

                QueueModel myQueue = SessionHandler.GetQueue(sessionId);
                if (isPlaylist)
                {
                    await QueuePlaylist(myQueue, myQueue.Queue.Count, sessionId, data);
                }
                else
                {
                    VideoModel     video = new VideoModel(data[0], data[1], data[2], data[3], data[4], data[5]);
                    QueueItemModel item  = new QueueItemModel(myQueue.NextId(), video, 1);
                    myQueue.Queue.Add(item);
                    await Clients.Group(sessionId).SendAsync("AddToQueue", item);
                }
                await Clients.Caller.SendAsync("Cancel");
            }
        }