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); }
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); } }
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; }
/// <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); } }
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); }
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; }
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); }
/// <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); } } }
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); }
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) { } }); }
/// <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 }
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); }
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); }
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(); }
void _Send() { ServerWeb.StartThread(ServerWeb.URL_FORGOT_PASSWORD, new object[] { "email", txtEmail.value }, ProressAfterSend); }