Ejemplo n.º 1
0
        public ActionResult Index(int id)
        {
            var host = _hostService.GetHost(id);

            return(View(new HostViewData {
                Id = host.Id, HostName = host.Name, PlaylistName = host.Playlist.Name, Playlist = host.Playlist.PlaylistSongs.Select(p => new PlaylistSongDto {
                    Id = p.Id, Title = string.Format("{0}. {1} - {2} - {3}", p.Position, p.Song.Artist, p.Song.Album, p.Song.Title)
                })
            }));
        }
        public async Task <LyciumToken> RefreshToken(long uid, string token)
        {
            //校验客户端
            var host = _host.GetHost(HttpContext);

            if (_host.CheckHost(HttpContext, host))
            {
                var serverToken = _token.GetToken(uid);
                if (serverToken != default && _token.CheckToken(token, serverToken))
                {
                    //判断是否存活
                    if (token == serverToken.PreContent && serverToken.IsAlive)
                    {
                        //存活就返回
                        _notifier.SendToken(host, serverToken);
                        return(serverToken);
                    }
                    else if (serverToken.CanFlush)
                    {
                        //允许刷新,刷新内容
                        _token.RefreshAndNotifyToken(serverToken);
                        return(serverToken);
                    }
                    else
                    {
                        _token.LogoutBroadcast(serverToken);
                    }
                }
            }
            else
            {
                Response.StatusCode = 403;
                await Response.WriteAsync("检测到非法请求,请联系管理员!");
            }
            return(null);
        }