IEnumerator DoRequest_AllHelp()
    {
        string reRequest = null;

        ServerWeb.StartThreadHttp(ServerWeb.URL_GETINFO_HELP, new object[] { "game_id", (int)GameManager.GAME, ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier }, delegate(bool isDone, WWW response, IDictionary json)
        {
            if (isDone)
            {
                if (string.IsNullOrEmpty(response.error))
                {
                    reRequest = "0";
                    if (json["code"].ToString() == "1")
                    {
                        string strSaveRule = JSON.JsonEncode(json["help"]);
                        StoreGame.SaveString(StoreGame.EType.CACHE_HELP, strSaveRule);
                        GameManager.Instance.StartCoroutine(onProcessGetInfoRule(strSaveRule, false));
                    }
                }
                else
                {
                    reRequest = "1";
                }
            }
        });
        while (string.IsNullOrEmpty(reRequest))
        {
            yield return(new WaitForEndOfFrame());
        }
        if (reRequest == "1")
        {
            yield return(new WaitForSeconds(2f));

            GameManager.Instance.StartCoroutine(DoRequest_AllHelp());
        }
    }
Beispiel #2
0
    void _Register()
    {
        WWWForm form = new WWWForm();

        form.AddField("username", iUsername.value);
        form.AddField("password", iPassword.value);
        if (email != null)
        {
            form.AddField("email", email);
        }
        if (!string.IsNullOrEmpty(sessionId))
        {
            Hashtable hashTable = new Hashtable();
            string    cookie    = sessionId.Split(";".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries)[0];
            if (Application.isWebPlayer)
            {
                Application.ExternalEval("document.cookie = " + cookie);
            }
            else
            {
                hashTable.Add("Cookie", cookie);
            }
            form.AddField(ServerWeb.PARAM_TYPE, ServerWeb.TYPE_REGISTER);
            form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
            ServerWeb.StartThread(ServerWeb.URL_GET_ACCESS_TOKEN, form, ProressAfterRegister, hashTable);
            return;
        }
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThread(ServerWeb.URL_QUICK_REGISTER, form, ProressAfterRegister);
    }
    /// <summary>
    /// Logged messages are sent through this callback function.
    /// </summary>
    /// <param name="message">The message itself.</param>
    /// <param name="stackTrace">A trace of where the message came from.</param>
    /// <param name="type">The type of message: error/exception, warning, or assert.</param>
    void HandleLog(string message, string stackTrace, LogType type)
    {
        ConsoleMessage entry = new ConsoleMessage(message, stackTrace, type);

        entries.Add(entry);

        if (type == LogType.Error && !message.StartsWith("Coroutine couldn't be started because the the game object"))
        {
            string  url  = ServerWeb.URL_REQUEST_ERROR;
            WWWForm form = new WWWForm();
            form.AddField("app_id", GameManager.GAME.ToString());
            form.AddField("game_version", GameSettings.CurrentVersion);
            if (GameManager.CurrentScene != ESceneName.LoginScreen)
            {
                form.AddField("user_id", GameManager.Instance.mInfo.id);
                form.AddField("username", GameManager.Instance.mInfo.username);
            }
            form.AddField("scene", GameManager.CurrentScene.ToString());
            form.AddField("error", message);
            form.AddField("detail", stackTrace);
            form.AddField("environment", Common.GetDevice);
            form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
            if (!listSendError.Contains(form))
            {
                listSendError.Add(form);
                ServerWeb.StartThread(url, form, null);
            }
        }

        if (entries.Count > limitLine)
        {
            entries.RemoveAt(0);
        }
    }
Beispiel #4
0
    void OnClickSendFeedBack(GameObject go)
    {
        if (isFeedBackClicked)
        {
            return;
        }

        if (!Utility.Input.IsStringValid(txtContent.value, 10, 999999))
        {
            NotificationView.ShowMessage("Nội dung bạn gửi quá ngắn.\n\nHãy nhập một lời góp ý trên 10 ký tự", 3f);
            return;
        }

        ServerWeb.StartThread(ServerWeb.URL_SEND_FEEDBACK,
                              new object[] { "game_id", (int)GameManager.GAME, "user_id", GameManager.Instance.mInfo.id, "title", txtTitle.value, "content", txtContent.value },
                              CallBackResponse);
        if (CBSendLog.value == true)
        {
            //LogViewer.SaveLogToFile();//for test
            LogViewer.SendLogToServer();
            CBSendLog.value = false;
            //Debug.LogWarning("Đã gửi debug_log");
        }
        isFeedBackClicked = true;
    }
    void OnLogin(LoginResponse response)
    {
        if (response.Successful)
        {
            ServerWeb.StartThread(ServerWeb.URL_REQUEST_USER, new object[] { "username", GameManager.Instance.mInfo.username }, delegate(bool isDone, WWW res, IDictionary json) {
            });
            GameManager.Instance.mInfo.password = lablePassword.value;
            GameManager.Server.DoJoinRoom(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId);

#if UNITY_WEBPLAYER
            if (!hasAccessToken)
            {
                Application.ExternalEval("ajaxLoginUnity(\"" + lableUsername.text + "\", \"" + lablePassword.text + "\");");
            }
#endif
        }
        else
        {
            IsClickButtonLogin = false;
            string message = "Thông tin đăng nhập không hợp lệ. Yêu cầu nhập lại thông tin truy cập.";
            if (response.EsObject.variableExists("reason"))
            {
                message = response.EsObject.getString("reason");
            }
            NotificationView.ShowMessage(message);
        }
    }
Beispiel #6
0
    public static void SendLogToServer()
    {
        StoreGame.ClearLog();
        for (int i = 0; i < entriesConsole.Count; i++)
        {
            StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, entriesConsole[i].message);
        }
        string  url  = ServerWeb.URL_REQUEST_ERROR;
        string  data = ConvertStringToJson(StoreGame.LoadString(StoreGame.EType.DEBUG_LOG));
        WWWForm form = new WWWForm();

        form.AddField("app_id", GameManager.GAME.ToString());
        form.AddField("game_version", GameSettings.CurrentVersion);
        if (GameManager.CurrentScene != ESceneName.LoginScreen)
        {
            form.AddField("user_id", GameManager.Instance.mInfo.id);
            form.AddField("username", GameManager.Instance.mInfo.username);
        }
        form.AddField("scene", GameManager.CurrentScene.ToString());
        form.AddField("error", "");
        form.AddField("detail", "");
        form.AddField("environment", Common.GetDevice);
        form.AddField("debug_log", data);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThread(url, form, null);
    }
Beispiel #7
0
    public void SetData(PrefabMessageTabbarControllerView controller, List <Messages> _listMessage)
    {
        tabbarController = controller;
        listMessage      = _listMessage;
        if (listMessage[0].sender_name == GameManager.Instance.mInfo.username)
        {
            username.text = listMessage[0].receiver_name;
            username.text = CutString(username.text);
        }
        else
        {
            username.text = listMessage[0].sender_name;
            username.text = CutString(username.text);
        }
        listMessage.Sort((x, y) => x.time_sent.CompareTo(y.time_sent));
        //GameManager.Instance.mInfo.AvatarTexture(delegate(Texture _texture) { avatar.mainTexture = _texture; });
        //Debug.Log
        ServerWeb.GetAvatarFromId(GameManager.Instance.mInfo.id == listMessage[0].receiver ? listMessage[0].sender_avatar : listMessage[0].receiver_avatar,
                                  delegate(Texture _avatar) {
            if (avatar != null)
            {
                avatar.mainTexture = _avatar;
            }
        });

        numberNoneRead = listMessage.FindAll(m => m.receiver_name == GameManager.Instance.mInfo.username && m.read == false).Count;
        SetCountNumber(numberNoneRead);
    }
    void ExecuteCommand(string text)
    {
        Dictionary <string, string> command = ParseCommandText(text);

        switch (GetCommand(command))
        {
        case "cls":
            entries.Clear();
            break;

        case "check":
            int entryId = int.Parse(GetParam(command, "entry", 0).Trim().ToLower());
            Debug.Log(entries[entryId].stackTrace);
            break;

        case "watch":

            break;

        case "canViewHand":
            Common.CanViewHand = !Common.CanViewHand;
            break;

        case "canTestMode":
            Common.CanTestMode = !Common.CanTestMode;
            break;

        case "close":
            showLogs = false;
            break;

        //case "bot":
        //    int number = 0;
        //    if (int.TryParse(command["max"], out number))
        //        if (number > 0 && number <= 3)
        //            GameSettings.MAX_NUMBER_BOT = number;
        //    break;
        case "call":
            if (command.ContainsKey("url"))
            {
                ServerWeb.StartThread(command["url"].ToString(), null);
            }
            break;

        case "help":
            Debug.Log(
                "Danh sách các command hỗ trợ trong Test Mode \n\n" +
                "\tclose           \t\t\tĐóng cửa sổ\n\n" +
                "\tcls             \t\t\tClear danh sách\n\n" +
                "\thelp            \t\t\tHiện thị các command\n\n" +
                "\tdisableTouch    \t\tDùng chuột trên mobile\n\n" +
                "\tcanViewHand     \tCho phép xem bài của đối thủ\n\n" +
                "\tcanTestMode     \tCho phép chế độ Test Mode\n\n" +
                "\tbot max=3       \t\tCho phép 3 bot khi chơi\n\n"
                );
            break;
        }
    }
    public void Execute()
    {
        WaitingView.Show("Chờ xử lý");
        AttributeRechargeCard attribute = Utility.EnumUtility.GetAttribute <AttributeRechargeCard>(model.ETypeCard);

        ServerWeb.StartThread(ServerWeb.URL_SEND_RECHARGE, new object[] { "username", GameManager.Instance.mInfo.username, "txtSoSeri", serial.value, "txtSoPin",
                                                                          cardCode.value, "select_method", attribute.text_id }, ProcessAfterRecharge);
        flag = false;
    }
    IEnumerator onProcessGetInfoRule(string textJson, bool isCache)
    {
        string reRequest = null;

        ArrayList list = (ArrayList)JSON.JsonDecode(textJson);

        foreach (Hashtable obj in list)
        {
            GameManager.Instance.ListHelp.Add(obj);
        }

        if (list.Count > 0)
        {
            //GameManager.Instance.ListHelp.Sort((x, y) => DateTime.Parse(x["time"].ToString()).CompareTo(DateTime.Parse(y["time"].ToString())));
            GameManager.Instance.ListHelp.Sort((x, y) => int.Parse(x["id"].ToString()).CompareTo(int.Parse(y["id"].ToString())));

            if (isCache)
            {
                WWWForm form = new WWWForm();
                string  time = string.Format("{0:yyyy-MM-dd HH:mm:ss}", GameManager.Instance.ListHelp[list.Count - 1]["time"].ToString());
                form.AddField("time", time);
                form.AddField("game_id", (int)GameManager.GAME);
                form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
                ServerWeb.StartThreadHttp(ServerWeb.URL_GETINFO_HELP, form, delegate(bool isDone, WWW response, IDictionary json)
                {
                    if (isDone)
                    {
                        if (string.IsNullOrEmpty(response.error))
                        {
                            reRequest = "0";
                            if (json["code"].ToString() == "1")
                            {
                                StoreGame.Remove(StoreGame.EType.CACHE_HELP);
                                GameManager.Instance.ListHelp.Clear();
                                GameManager.Instance.StartCoroutine(DoRequest_AllHelp());
                            }
                        }
                        else
                        {
                            reRequest = "1";
                        }
                    }
                });
                while (string.IsNullOrEmpty(reRequest))
                {
                    yield return(new WaitForEndOfFrame());
                }
                if (reRequest == "1")
                {
                    yield return(new WaitForSeconds(2f));

                    GameManager.Instance.StartCoroutine(DoRequest_AllHelp());
                }
            }
        }
    }
    public void _ChangeAvatar(Texture2D texture)
    {
        User    user = GameManager.Instance.mInfo;
        string  data = convertUserInfoToJson(user, texture);
        WWWForm form = new WWWForm();

        form.AddField(ServerWeb.PARAM_TYPE, ServerWeb.TYPE_CHANGE_AVATAR);
        form.AddField(ServerWeb.PARAM_DATA, data);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThread(ServerWeb.URL_CHANGE_INFORMATION, form, ProcessAfterChangeAvatar);
    }
Beispiel #12
0
    /// <summary>
    /// Khởi tạo cho sự kiện hoặc quảng cáo
    /// </summary>
    public Announcement(int index, string description, Scene show, string gotoUrl, string imageUrl, Type type)
    {
        this.index       = index;
        this.description = description;
        this.url         = gotoUrl;
        this.type        = type;
        this.show        = show;
        this.imageUrl    = imageUrl;

        ServerWeb.GetImageFromUrl(imageUrl, "", delegate(UnityEngine.Texture texture) { _image = texture; });
    }
Beispiel #13
0
    /// <summary>
    /// Logged messages are sent through this callback function.
    /// </summary>
    /// <param name="message">The message itself.</param>
    /// <param name="stackTrace">A trace of where the message came from.</param>
    /// <param name="type">The type of message: error/exception, warning, or assert.</param>
    void HandleLog(string message, string stackTrace, LogType type)
    {
        ConsoleMessage entry = new ConsoleMessage(message, stackTrace, type);

        entries.Add(entry);
        if (entries.Count > LIMIT_LINE)
        {
            entries.RemoveAt(0);
        }

        if (GameManager.CurrentScene == ESceneName.GameplayChan && type == LogType.Exception)
        {
            WaitingView.Show("Có l?i x?y ra. Vui lòng d?i!");
            GameManager.Server.DoRequestGameCommand("refreshGame");
        }


        entriesConsole.Add(entry);
        if (entriesConsole.Count > LIMIT_LINE_CONSOLE)
        {
            entriesConsole.RemoveAt(0);
        }

        if (type == LogType.Error && !message.StartsWith("Coroutine couldn't be started because the the game object"))
        {
            StoreGame.ClearLog();
            for (int i = 0; i < entries.Count; i++)
            {
                StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, entries[i].message);
            }
            //SaveLogToFile(); //for test
            string  url  = ServerWeb.URL_REQUEST_ERROR;
            string  data = ConvertStringToJson(StoreGame.LoadString(StoreGame.EType.DEBUG_LOG));
            WWWForm form = new WWWForm();
            form.AddField("app_id", GameManager.GAME.ToString());
            form.AddField("game_version", GameSettings.CurrentVersion);
            if (GameManager.CurrentScene != ESceneName.LoginScreen)
            {
                form.AddField("user_id", GameManager.Instance.mInfo.id);
                form.AddField("username", GameManager.Instance.mInfo.username);
            }
            form.AddField("scene", GameManager.CurrentScene.ToString());
            form.AddField("error", "");
            form.AddField("detail", "");
            form.AddField("environment", Common.GetDevice);
            form.AddField("debug_log", data);
            form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
            if (!listSendError.Contains(form))
            {
                listSendError.Add(form);
                ServerWeb.StartThread(url, form, null);
            }
        }
    }
Beispiel #14
0
    public void SetData(Messages message)
    {
        lbUsername.text = message.sender_name;           // GameManager.Instance.mInfo.username == message.receiver_name ? message.sender_name : message.receiver_name;
        lbContent.text  = message.content;               // +" Mỗi lần xuất hiện, hai bé gái song sinh nhà của ngôi sao ‘Sex and the City’, Sarah Jessica Parker luôn gây chú ý về vẻ dễ thương cùng gu ăn mặc sành điệu.";

        ServerWeb.GetAvatarFromId(message.sender_avatar, // GameManager.Instance.mInfo.username == message.receiver_name ? message.sender_avatar : message.receiver_avatar,
                                  delegate(Texture _avatar) { if (avatar != null)
                                                              {
                                                                  avatar.mainTexture = _avatar;
                                                              }
                                  });
    }
    IEnumerator DoRequestAds()
    {
        string isReRequest = null;

        ServerWeb.StartThreadHttp(ServerWeb.URL_GET_ADS, new object[] { ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier }, delegate(bool isDone, WWW response, IDictionary json)
        {
            if (isDone)
            {
                if (string.IsNullOrEmpty(response.error))
                {
                    isReRequest = "0";
                    if (json["code"].ToString() == "1")
                    {
                        ArrayList list = (ArrayList)json["item"];
                        foreach (Hashtable obj in list)
                        {
                            Announcement announce = new Announcement(
                                Convert.ToInt32(obj["index"]),
                                obj["description"].ToString(),
                                obj["scenes"].ToString() == "lobby"
                                    ? Announcement.Scene.lobby
                                    : obj["scenes"].ToString() == "login"
                                    ? Announcement.Scene.login
                                    : Announcement.Scene.announce,
                                obj["url"].ToString(),
                                obj["image"].ToString(),
                                obj["type"].ToString() == "Ads" ? Announcement.Type.Advertisement : Announcement.Type.Event
                                );
                            GameManager.Instance.ListAnnouncement.Add(announce);
                        }
                        if (EventLoadAnnounce != null)
                        {
                            EventLoadAnnounce();
                        }
                    }
                }
                else
                {
                    isReRequest = "1";
                }
            }
        }, null);
        while (string.IsNullOrEmpty(isReRequest))
        {
            yield return(new WaitForEndOfFrame());
        }
        if (isReRequest == "1")
        {
            yield return(new WaitForSeconds(2f));

            GameManager.Instance.StartCoroutine(DoRequestAds());
        }
    }
    IEnumerator DoRequestVersion()
    {
        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.isEditor)
        {
            bool?   reRequest = null;
            WWWForm form      = new WWWForm();
            form.AddField("version", (GameSettings.Instance.CODE_VERSION_BUILD));
            form.AddField("offical_version", GameSettings.CurrentVersion);
            form.AddField("game_id", (int)GameManager.GAME);
            form.AddField("device", PlatformSetting.GetPlatform.ToString());
            form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
            ServerWeb.StartThreadHttp(ServerWeb.URL_GET_VERSION_GAME, form, delegate(bool isDone, WWW response, IDictionary json)
            {
                if (isDone)
                {
                    if (string.IsNullOrEmpty(response.error))
                    {
                        reRequest = false;
                        if (json["code"].ToString() == "1")
                        {
                            string url = json["link"].ToString();
                            GameManager.Setting.IsMustUpdate = url;
                            Common.MustUpdateGame();
                        }
                        else if (json["code"].ToString() == "2")
                        {
                            string newVersion = json["core_version"].ToString() + "." + json["build_version"].ToString() + "." + json["code_version_build"].ToString();
                            string url        = json["link"].ToString();

                            NotificationView.ShowConfirm("Cập nhật phiên bản mới", "Hiện tại chúng tôi đã có phiên bản mới v" + newVersion + "\n\n" + "Hãy cập nhật và cảm nhận những tính năng mới.",
                                                         delegate() { Application.OpenURL(url); },
                                                         null, "CẬP NHẬT", "ĐỂ SAU");
                        }
                    }
                    else
                    {
                        reRequest = true;
                    }
                }
            });
            while (reRequest == null)
            {
                yield return(new WaitForEndOfFrame());
            }
            if (reRequest == true)
            {
                yield return(new WaitForSeconds(2f));

                GameManager.Instance.StartCoroutine(DoRequestVersion());
            }
        }
    }
    void _ChangePassword()
    {
        User      user = GameManager.Instance.mInfo;
        Hashtable hash = new Hashtable();

        hash.Add("username", user.username);
        hash.Add("password", txtOldPass.value);
        hash.Add("newPassword", txtNewPass.value);
        hash.Add("renewPassword", txtRenewPass.value);
        string data = JSON.JsonEncode(hash);

        ServerWeb.StartThread(ServerWeb.URL_CHANGE_INFORMATION, new object[] { ServerWeb.PARAM_TYPE, ServerWeb.TYPE_CHANGE_PASSWORD, ServerWeb.PARAM_DATA, data }, ProcessAfterChangePass);
    }
Beispiel #18
0
 public void LoadTexture(CallBackDownloadImage callback)
 {
     if (_image != null)
     {
         callback(_image);
     }
     else
     {
         ServerWeb.GetImageFromUrl(imageUrl, "", delegate(UnityEngine.Texture texture)
         {
             _image = texture;
             callback(_image);
         });
     }
 }
Beispiel #19
0
 void remoteRegistrationSucceeded(string deviceToken)
 {
     if (CurrentScene != ESceneName.LoginScreen)
     {
         EsObject eso = Utility.SetEsObject("updateDeviceToken", new object[] { "deviceToken", deviceToken, "platform", PlatformSetting.GetSamplePlatform.ToString() });
         Server.DoRequestPlugin(eso);
     }
     this.deviceToken = deviceToken;
     ServerWeb.StartThread(ServerWeb.URL_REQUEST_SAVE_ACCESSTOKEN, new object[] { ServerWeb.PARAM_DEVICE_TOKEN, deviceToken, ServerWeb.PARAM_PLATFORM, PlatformSetting.GetSamplePlatform.ToString() }, delegate(bool isDone, WWW response, IDictionary json)
     {
         if (isDone)
         {
         }
     });
 }
Beispiel #20
0
    /// <summary>
    /// Load tin nhắn hệ thống từ cache của game và kiểm tra tin nhắn mới từ database
    /// </summary>
    public static void DownloadOrLoadCache()
    {
        GameManager.Instance.ListMessageSystem.Clear();
        if (StoreGame.Contains(StoreGame.EType.CACHE_MESSAGE_SYSTEM))
        {
            ArrayList cacheMessageSystem = (ArrayList)JSON.JsonDecode(StoreGame.LoadString(StoreGame.EType.CACHE_MESSAGE_SYSTEM));

            foreach (Hashtable hash in cacheMessageSystem)
            {
                GameManager.Instance.ListMessageSystem.Add(new Messages(hash));
            }

            GameManager.Instance.ListMessageSystem.Sort((x, y) => x.time_sent.CompareTo(y.time_sent));
        }

        #region DOWNLOAD
        WWWForm formMessageSystem = new WWWForm();
        formMessageSystem.AddField("sender", 0);
        formMessageSystem.AddField("receiver", GameManager.Instance.mInfo.id);
        formMessageSystem.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        if (GameManager.Instance.ListMessageSystem.Count > 0)
        {
            DateTime time_send = GameManager.Instance.ListMessageSystem[GameManager.Instance.ListMessageSystem.Count - 1].time_sent;
            formMessageSystem.AddField("time", string.Format("{0:yyyy-MM-dd HH:mm:ss}", time_send));
            //Debug.Log(ServerWeb.URL_GETINFO_MESSAGE + "?sender=0&receiver=" + GameManager.Instance.mInfo.id + "&time=" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", time_send));
        }

        ServerWeb.StartThread(ServerWeb.URL_GETINFO_MESSAGE, formMessageSystem, delegate(bool isDone, WWW response, IDictionary json)
        {
            var x = json;
            if (isDone && json["code"].ToString() == "1")
            {
                ArrayList downloadMessageSystem = (ArrayList)json["item"];
                List <Hashtable> lst            = new List <Hashtable>();
                foreach (Hashtable hash in downloadMessageSystem)
                {
                    lst.Add(hash);
                }
                SaveCache(lst.ToArray());
                if (EventResponseMessageSystem != null)
                {
                    EventResponseMessageSystem();
                }
            }
        });
        #endregion
    }
    IEnumerator DoRequestRecharge()
    {
        string  reRequest = null;
        WWWForm form      = new WWWForm();

        form.AddField(ServerWeb.PARAM_CONFIG_CODE_GAME, GameManager.GAME.ToString());
        form.AddField(ServerWeb.PARAM_CONFIG_CODE_PLATFORM, PlatformSetting.GetPlatform.ToString());
        form.AddField(ServerWeb.PARAM_CONFIG_CORE_VERSION, GameSettings.Instance.CORE_VERSION);
        form.AddField(ServerWeb.PARAM_CONFIG_BUILD_VERSION, GameSettings.Instance.BUILD_VERSION);
        form.AddField(ServerWeb.PARAM_CONFIG_CODE_REVISION, GameSettings.Instance.CODE_VERSION_BUILD);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThreadHttp(ServerWeb.URL_GET_RECHARGE, form, delegate(bool isDone, WWW response, IDictionary json)
        {
            if (isDone)
            {
                if (string.IsNullOrEmpty(response.error))
                {
                    reRequest = "0";
                    if (json["code"].ToString() == "1")
                    {
                        ArrayList items = (ArrayList)json["items"];
                        foreach (Hashtable obj in items)
                        {
                            RechargeModel model = new RechargeModel(obj);
                            GameManager.Instance.ListRechargeModel.Add(model);
                        }
                    }
                }
                else
                {
                    reRequest = "1";
                }
            }
        }, null);

        while (string.IsNullOrEmpty(reRequest))
        {
            yield return(new WaitForEndOfFrame());
        }
        if (reRequest == "1")
        {
            yield return(new WaitForSeconds(2f));

            GameManager.Instance.StartCoroutine(DoRequestRecharge());
        }
    }
    void _ChangeSecurityInfor()
    {
        User user = new User();

        user.username = GameManager.Instance.mInfo.username;
        user.email    = txtEmail.value;
        user.phone    = txtPhone.value;
        user.cmtnd    = txtCMTND.value;

        String json = convertUserInfoToJson(user);

        WWWForm form = new WWWForm();

        form.AddField(ServerWeb.PARAM_TYPE, ServerWeb.TYPE_CHANGE_SECURITY_INFO);
        form.AddField(ServerWeb.PARAM_DATA, json);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThread(ServerWeb.URL_CHANGE_INFORMATION, form, ProcessAfterChangeSecurityInformation);
    }
    void _ChangeInformation()
    {
        //string[] array = txtFullname.value.Split(" ".ToCharArray(), StringSplitOptions.None);
        string[] array = txtFullname.value.Trim().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

        User user = GameManager.Instance.mInfo;

        user.firstName = user.lastName = user.middleName = "";
        if (array.Length > 2)
        {
            user.lastName   = array[0];
            user.firstName  = array[array.Length - 1];
            user.middleName = "";
            for (int i = 1; i < array.Length - 1; i++)
            {
                user.middleName += array[i] + " ";
            }
        }
        else if (array.Length == 1)
        {
            user.firstName = array[0];
        }
        else if (array.Length == 2)
        {
            user.lastName  = array[0];
            user.firstName = array[array.Length - 1];
        }

        string birthday = txtDay.value + "/" + txtMonth.value + "/" + txtYear.value;

        user.brithday = Utility.Convert.StringToTime(birthday, "vi-VN");
        user.address  = txtAddress.value;
        user.gender   = cbMale.value ? "male" : "female";
        String json = convertUserInfoToJson(user);

        WWWForm form = new WWWForm();

        form.AddField(ServerWeb.PARAM_TYPE, ServerWeb.TYPE_CHANGE_INFO);
        form.AddField(ServerWeb.PARAM_DATA, json);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        WaitingView.Show("Đang lưu thông tin");
        ServerWeb.StartThread(ServerWeb.URL_CHANGE_INFORMATION, form, ProcessAfterChangeInformation);
    }
Beispiel #24
0
    public void LoginWithAccessToken(ETypeSocial social)
    {
        CallBackResponse callBack = null;
        WWWForm          form     = new WWWForm();

        form.AddField(ServerWeb.PARAM_TYPE, social.ToString());
        form.AddField(ServerWeb.PARAMS_ACCESS_TOKEN, (social == ETypeSocial.facebook ? FB.AccessToken : social == ETypeSocial.google ? Google.instance.accessToken : social == ETypeSocial.twitter ? "" : ""));
        form.AddField(ServerWeb.PARAMS_APP_ID, Convert.ToString(GameManager.GAME));
        switch (social)
        {
        case ETypeSocial.facebook:
            callBack = ProressAfterLoginFacebook;
            break;

        case ETypeSocial.google:
            callBack = ProressAfterLoginGoogle;
            break;
        }
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThread(ServerWeb.URL_GET_ACCESS_TOKEN, form, callBack);
    }
    IEnumerator DoRequestAllConfiguration(string message)
    {
        int getConfigurationCount = 0;

        WaitingView.Show(message);
        bool?   reRequest = null;
        WWWForm form      = new WWWForm();

        form.AddField(ServerWeb.PARAM_CONFIG_CODE_GAME, GameManager.GAME.ToString());
        form.AddField(ServerWeb.PARAM_CONFIG_CODE_PLATFORM, PlatformSetting.GetPlatform.ToString());
        form.AddField(ServerWeb.PARAM_CONFIG_CORE_VERSION, GameSettings.Instance.CORE_VERSION);
        form.AddField(ServerWeb.PARAM_CONFIG_BUILD_VERSION, GameSettings.Instance.BUILD_VERSION);
        form.AddField(ServerWeb.PARAM_CONFIG_CODE_REVISION, GameSettings.Instance.CODE_VERSION_BUILD);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThreadHttp(ServerWeb.URL_GET_ALL_CONFIGURATION, form, delegate(bool isDone, WWW response, IDictionary json)
        {
            if (isDone)
            {
                GameManager.Instance.FunctionDelay(delegate()
                {
                    if (string.IsNullOrEmpty(response.error))
                    {
                        WaitingView.Instance.Close();
                        reRequest = false;
                        if (json[Fields.RESPONSE.PHP_RESPONSE_CODE].ToString() == "0")
                        {
                            ArrayList items = (ArrayList)json[Fields.RESPONSE.PHP_RESPONSE_ITEMS];
                            foreach (Hashtable obj in items)
                            {
                                GameManager.Setting.Platform.AddOrUpdatePlatformConfig(obj);
                            }
                            if (GameManager.CurrentScene == ESceneName.ChannelChan)
                            {
                                //HeaderMenu.Instance.ActiveButtonRecharge();
                            }
                            if (GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping) != null)
                            {
                                ServerWeb.URL_PING = GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping).Value;
                            }

                            if (GameManager.Setting.Platform.GetConfigByType(PlatformType.realtime_server) != null)
                            {
                                CServer.HOST_NAME = GameManager.Setting.Platform.GetConfigByType(PlatformType.realtime_server).Value;
                            }

                            if (EventLoadConfig != null)
                            {
                                EventLoadConfig();
                            }
                        }
                    }
                    else
                    {
                        reRequest = true;
                    }
                }, 0.2f);
            }
        });
        while (reRequest == null)
        {
            yield return(new WaitForEndOfFrame());
        }
        if (reRequest == true)
        {
            getConfigurationCount++;
            if (getConfigurationCount < 3)
            {
                yield return(new WaitForSeconds(1f));

                GameManager.Instance.StartCoroutine(DoRequestAllConfiguration("Kết nối bị lỗi , Đang kiểm tra lại kết nối "));
            }
            else
            {
                NotificationView.ShowConfirm("Thông báo", "Không thể kết nối đến server của chúng tôi . Bấm đồng ý để tiếp tục kiểm tra lại ", delegate()
                {
                    getConfigurationCount = 0;
                    GameManager.Instance.StartCoroutine(DoRequestAllConfiguration("Kiểm tra kết nối đến server"));
                }, null);
            }
        }
    }
 void _Send()
 {
     ServerWeb.StartThread(ServerWeb.URL_FORGOT_PASSWORD, new object[] { "email", txtEmail.value }, ProressAfterSend);
 }
    void PluginMessageOnProcess(string command, string action, EsObject PluginMessageParameters)
    {
        if (command == Fields.RESPONSE.LOGIN_RESPONSE)
        {
            Debug.Log("OnLoginResponse " + PluginMessageParameters);
            Debug.Log("Đã nhận được thông tin server");
            EsObject esoResponce = PluginMessageParameters;

            if (esoResponce.getBoolean("loginResult"))
            {
                if (esoResponce.variableExists("gifts"))
                {
                    EsObject[] esoGifts = esoResponce.getEsObjectArray("gifts");
                    int        index    = Array.FindIndex(esoGifts, eI => eI.getBoolean("currentDate") == true);
                    if (esoGifts.Length > 0)
                    {
                        for (int i = 0; i < esoGifts.Length; i++)
                        {
                            Announcement ann = new Announcement(esoGifts[i]);
                            ann.index       = i;
                            ann.description = "Ngày " + (i + 1);
                            if (i < index)
                            {
                                ann.receivered = true;
                            }
                            GameManager.Instance.ListAnnouncement.Add(ann);
                        }
                    }
                }
                if (esoResponce.variableExists("countUnReadMessage"))
                {
                    GameManager.Server.totalMesseageCount = esoResponce.getInteger("countUnReadMessage");
                }

                GameManager.Setting.BroadcastMessage = esoResponce.getString("broadCastMessage");
                //GameManager.Instance.channelRoom = new RoomInfo(esoResponce.getEsObject("firstRoomToJoin"));
                GameManager.Instance.hallRoom = new RoomInfo(esoResponce.getEsObject("firstRoomToJoin"));
                GameManager.Instance.mInfo    = new User(esoResponce.getEsObject("userInfo"));

                if (esoResponce.variableExists("ceo_chan"))
                {
                    Common.RULE_CHIP_COMPARE_BETTING = esoResponce.getInteger("ceo_chan");
                }
                if (esoResponce.variableExists("pingRequire"))
                {
                    GameManager.Setting.IsPingRequire = esoResponce.getBoolean("pingRequire");
                }



                if (esoResponce.variableExists("gameRoom"))
                {
                    ((LobbyChan)GameManager.Instance.selectedLobby).SetDataJoinLobby(esoResponce.getEsObject("gameRoom"));
                    GameManager.Instance.selectedChannel.SetDataRoom(esoResponce.getEsObject("gameRoom").getEsObject("gameDetails").getEsObject("parent"));
                    GameManager.Instance.currentRoom = new RoomInfo(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId);
                    GameManager.Server.DoJoinGame(((LobbyChan)GameManager.Instance.selectedLobby).config.password);
                    GameManager.LoadScene(ESceneName.GameplayChan);
                    return;
                }

                ServerWeb.StartThread(ServerWeb.URL_REQUEST_USER, new object[] { "username", GameManager.Instance.mInfo.username }, delegate(bool isDone, WWW res, IDictionary json)
                {
                });
                GameManager.Instance.mInfo.password = lablePassword.value;
                GameManager.Server.DoJoinRoom(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId);
#if UNITY_WEBPLAYER
                if (!hasAccessToken)
                {
                    Application.ExternalEval("ajaxLoginUnity(\"" + GameManager.Instance.userNameLogin + "\", \"" + GameManager.Instance.passwordLogin + "\");");
                }
#endif
                if (!cbSavePass.value)
                {
                    StoreGame.Remove(StoreGame.EType.SAVE_USERNAME);
                    StoreGame.Remove(StoreGame.EType.SAVE_PASSWORD);
                    StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN);
                    GameManager.Instance.userNameLogin = GameManager.Instance.passwordLogin = GameManager.Instance.accessToken = "";
                }
                else
                {
                    StoreGame.SaveString(StoreGame.EType.SAVE_USERNAME, GameManager.Instance.userNameLogin);
                    StoreGame.SaveString(StoreGame.EType.SAVE_PASSWORD, GameManager.Instance.passwordLogin);
                    StoreGame.SaveString(StoreGame.EType.SAVE_ACCESSTOKEN, GameManager.Instance.accessToken);
                }
            }
            else
            {
                Debug.Log("Login false");
                IsClickButtonLogin = false;
                StoreGame.Remove(StoreGame.EType.SAVE_USERNAME);
                StoreGame.Remove(StoreGame.EType.SAVE_PASSWORD);
                StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN);
                GameManager.Instance.userNameLogin = GameManager.Instance.passwordLogin = GameManager.Instance.accessToken = "";

                string message = "Thông tin đăng nhập không hợp lệ. Yêu cầu nhập lại thông tin truy cập.";
                if (!string.IsNullOrEmpty(esoResponce.getString("reason")))
                {
                    message = esoResponce.getString("reason");
                }
                NotificationView.ShowMessage(message);
            }
        }

        WaitingView.Instance.Close();
    }
Beispiel #28
0
    public void SetDataUser(Electrotank.Electroserver5.Api.EsObject obj)
    {
        if (obj.variableExists("id"))
        {
            id = obj.getInteger("id");
        }

        if (obj.variableExists("username"))
        {
            username = obj.getString("username");
        }
        else if (obj.variableExists(Fields.PLAYER.USERNAME))
        {
            username = obj.getString(Fields.PLAYER.USERNAME);
        }

        if (obj.variableExists("email"))
        {
            email = obj.getString("email");
        }
        if (obj.variableExists("first_name"))
        {
            firstName = obj.getString("first_name");
        }
        if (obj.variableExists("middle_name"))
        {
            middleName = obj.getString("middle_name");
        }
        if (obj.variableExists("last_name"))
        {
            lastName = obj.getString("last_name");
        }
        if (obj.variableExists("birthday"))
        {
            System.DateTime.TryParse(obj.getString("birthday").Replace(":", "-"), out brithday);
        }
        if (obj.variableExists("gender"))
        {
            gender = obj.getString("gender");
        }
        if (obj.variableExists("address"))
        {
            address = obj.getString("address");
        }
        if (obj.variableExists("identity_card_number"))
        {
            cmtnd = obj.getString("identity_card_number");
        }
        if (obj.variableExists("mobile"))
        {
            phone = obj.getString("mobile");
        }
        if (obj.variableExists("avatar"))
        {
            if (obj.getDataType("avatar") == DataType.String)
            {
                avatarUrl = obj.getString("avatar");
            }
            else if (obj.getDataType("avatar") == DataType.Integer)
            {
                ServerWeb.GetAvatarFromId(obj.getInteger("avatar"), delegate(Texture _texture) { _avatarTexture = _texture; });
            }
        }

        if (obj.variableExists("create_time"))
        {
            System.DateTime.TryParse(obj.getString("create_time"), out createTime);
        }
        if (obj.variableExists("time_request"))
        {
            System.DateTime.TryParse(obj.getString("time_request"), out timeRequest);
        }
        if (obj.variableExists("numBuddies"))
        {
            numberBuddies = obj.getInteger("numBuddies");
        }
        if (obj.variableExists("role"))
        {
            role = (ERole)obj.getInteger("role");
        }
        if (obj.variableExists("level"))
        {
            level = obj.getInteger("level");
        }
        if (obj.variableExists("experience"))
        {
            experience = obj.getInteger("experience");
        }
        if (obj.variableExists("expMinCurrentLevel"))
        {
            expMinCurrentLevel = obj.getInteger("expMinCurrentLevel");
        }
        if (obj.variableExists("expMinNextLevel"))
        {
            expMinNextLevel = obj.getInteger("expMinNextLevel");
        }

        if (obj.variableExists("buddies"))
        {
            if (buddies != null && buddies.Count > 0)
            {
                buddies.Clear();
            }
            EsObject[] array = obj.getEsObjectArray("buddies");
            Array.ForEach <EsObject>(array, o => { buddies.Add(new User(o)); });
        }
        if (obj.variableExists("pendingBuddies"))
        {
            if (pendingBuddies != null && pendingBuddies.Count > 0)
            {
                pendingBuddies.Clear();
            }
            EsObject[] array = obj.getEsObjectArray("pendingBuddies");
            Array.ForEach <EsObject>(array, o => { pendingBuddies.Add(new User(o)); });
        }
        if (obj.variableExists("requestBuddies"))
        {
            EsObject[] array = obj.getEsObjectArray("requestBuddies");
            Array.ForEach <EsObject>(array, o => { requestBuddies.Add(new User(o)); });
        }

        if (obj.variableExists("chip"))
        {
            if (obj.getDataType("chip") == DataType.String)
            {
                long.TryParse(obj.getString("chip"), out chip);
            }
            else if (obj.getDataType("chip") == DataType.Long)
            {
                chip = obj.getLong("chip");
            }
        }

        if (obj.variableExists("gold"))
        {
            if (obj.getDataType("gold") == DataType.String)
            {
                long.TryParse(obj.getString("gold"), out gold);
            }
            else if (obj.getDataType("gold") == DataType.Long)
            {
                gold = obj.getLong("gold");
            }
        }

        if (obj.variableExists("accessToken"))
        {
            accessToken = obj.getString("accessToken");
        }
    }