<%@ Page Language="C#" AutoEventWireup="true" %>

<%--
    帝王霸业
--%>
<script runat="server">
    protected override void OnError(EventArgs e)
    {
        Server.ClearError();
        Response.Clear();
        Response.Write("其他错误");
    }
    
    protected override void OnInit(EventArgs e)
    {
        string sidx = Request.Params["xysid"];
        string uidx = Request.Params["xyuid"];
        var _server = new com.xykj.business.View.Games.Server();
        var server = _server.GetServer(XY.ToInt(sidx));
        if (server == null)
        {
            Response.Write("不存在的服务器");
            return;
        }
        var port = new com.xykj.business.View.Games.Port().GetPortByGameId(server.GameId);
        var user = new com.xykj.business.View.Account.Account().GetUserByAccount(uidx);
        if (user == null)
        {
            Response.Write("不存在的用户");
            return;
        }
        
        string user_id = user.ID + "";
        string server_id = server.ServerNumber;
        string key = port.UserKey;
        string agent = port.Unid;
        string timestamp = XY.TimeSpan + "";
        string md5 = string.Format("{0}agent{1}server_id{2}timestamp{3}user_id{4}", key, agent, server_id, timestamp, user_id);
        string sign = XY.MD5(md5).ToUpper();
        string parm = string.Format("agent={0}&server_id={1}&timestamp={2}&user_id={3}&sign={4}", agent, server_id, timestamp, user_id, sign);
        string url = string.Format(port.UserUrl, server.ServerNumber2) + "?" + parm;
        string uRol = XY.GetUrlByStream(url, "utf-8");
        Response.Clear();
        Response.Write(uRol);
    }
</script>