Esempio n. 1
0
    public static WebRequest <uint> Register(string name, string password, OnRequestComplete <uint> onComplete = null)
    {
        var accountInfo = new AccountInfo {
            name = name, password = password.GetMD5()
        };

        return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_REGISTER), accountInfo, onComplete));
    }
Esempio n. 2
0
 public static WebRequest <AccountData> Login(string username, string password, bool guest, OnRequestComplete <AccountData> onComplete = null)
 {
     if (guest)
     {
         return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_AUTH_GUEST), new { name = username }, onComplete));
     }
     return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_AUTH), new { name = username, password = password.GetMD5() }, onComplete));
 }
Esempio n. 3
0
    public static WebRequest BindAcount(int accId, string name, string password, string devId = "", OnRequestComplete onComplete = null)
    {
        var accountInfo = new
        {
            account  = accId,
            new_name = name,
            password = password.GetMD5()
        };

        return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_ACCOUNT_BIAND), accountInfo, onComplete));
    }
Esempio n. 4
0
 public static WebRequest <List <BannerInfo> > GetBanner(OnRequestComplete <List <BannerInfo> > onComplete = null)
 {
     return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_BANNER_INFO), onComplete));
 }
Esempio n. 5
0
    public static WebRequest <bool> CheckAccount(string m_name, OnRequestComplete <bool> onComplete = null)
    {
        var accountInfo = new { name = m_name };

        return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_ACCOUNT_CHECK), accountInfo, onComplete));
    }
Esempio n. 6
0
 public static WebRequest <uint> Register(AccountInfo info, OnRequestComplete <uint> onComplete = null)
 {
     return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_REGISTER), info, onComplete));
 }
Esempio n. 7
0
 public static WebRequest <ServerStatus> GetServerStatus(OnRequestComplete <ServerStatus> onComplete = null)
 {
     return(WebRequestManager.Request(WebAPI.FullApiUrl(WebAPI.API_SERVER_STATUS), new { clientVersion = Launch.Updater.currentVersion }, onComplete));
 }
Esempio n. 8
0
    public IEnumerator _PostToServer(string rFileName)
    {
        while (!IsFileSaveComplete(rFileName + ".log"))
        {
            yield return(0);
        }

        var     account  = Module_Login.instance?.account;
        WWWForm postForm = new WWWForm();

        var playerName = string.Empty;

        if (Module_Player.instance != null)
        {
            playerName = Module_Player.instance.roleInfo.roleId.ToString();
        }
        var path     = gameLogger.GetFullPath(rFileName);
        var contents = Util.LoadFile(path);

        if (contents != null && contents.Length > 0)
        {
            postForm.AddBinaryData("logFile", contents, $"{rFileName }_{playerName}.log");
        }

        var request = UnityWebRequest.Post(WebAPI.FullApiUrl(WebAPI.RES_FIGHT_DATA), postForm);

        request.SetRequestHeader("Content-Type", postForm.headers["Content-Type"]);
        request.SetRequestHeader("Authorization", BasicAuth(account?.acc_name ?? "null", "123456"));
        request.SetRequestHeader("X-Game-Identity", $"kzwg/{rFileName}");

        request.timeout = 5;
        yield return(request.SendWebRequest());

        if (request.isNetworkError)
        {
            Logger.LogWarning($"日志文件上传失败:{request.url}");
            yield break;
        }
        Logger.LogWarning($"日志文件上传成功:{WebAPI.FullApiUrl(WebAPI.RES_FIGHT_DATA)} 数据大小:{contents.Length}");
        request.Dispose();

        while (!IsFileSaveComplete(rFileName + ".gr"))
        {
            yield return(0);
        }

        postForm = new WWWForm();
        path     = GameRecorder.GetFullPath(rFileName);
        contents = Util.LoadFile(path);
        if (contents != null && contents.Length > 0)
        {
            postForm.AddBinaryData("grFile", contents, $"{rFileName }_{playerName}.gr");
        }

        request = UnityWebRequest.Post(WebAPI.FullApiUrl(WebAPI.RES_FIGHT_DATA), postForm);
        request.SetRequestHeader("Content-Type", postForm.headers["Content-Type"]);
        request.SetRequestHeader("Authorization", BasicAuth(account?.acc_name ?? "null", "123456"));
        request.SetRequestHeader("X-Game-Identity", $"kzwg/{rFileName}");

        request.timeout = 5;
        yield return(request.SendWebRequest());

        if (request.isNetworkError)
        {
            Logger.LogWarning($"录像文件上传失败:{request.url}");
            yield break;
        }
        Logger.LogWarning($"录像文件上传成功:{WebAPI.FullApiUrl(WebAPI.RES_FIGHT_DATA)} 数据大小:{contents.Length}");
        request.Dispose();
    }