private IEnumerator Publish(string url) { WWW wWW = new WWW(url); WWWManager.Add(wWW); yield return(wWW); if (WWWManager.Remove(wWW)) { if (wWW.error == null) { this.wwwRetryCount = 0; } else { int num = this.wwwRetryCount + 1; this.wwwRetryCount = num; if (num < this.wwwMaxRetry) { Service.Get <Engine>().StartCoroutine(this.Publish(url)); Service.Get <StaRTSLogger>().Warn("Unable to publish chat message. Retrying: " + wWW.error); } else { Service.Get <StaRTSLogger>().Warn("Unable to publish chat: " + wWW.error); } } } wWW.Dispose(); yield break; }
private IEnumerator LoadImage(string url, ThumbnailManager.ImageLoadCompleteDelegate onLoadComplete) { WWW wWW = new WWW(url); WWWManager.Add(wWW); yield return(wWW); if (!WWWManager.Remove(wWW)) { yield break; } string error = wWW.error; Texture2D texture = wWW.texture; if (string.IsNullOrEmpty(error)) { this.Store(url, texture); onLoadComplete(texture); this.Remove(url); } else { Service.Get <StaRTSLogger>().ErrorFormat("Error fetching thumbnail at {0}", new object[] { url }); onLoadComplete(null); } wWW.Dispose(); yield break; }
public void LoginButton() { if (usernameIF.text != "" && passwordIF.text != "") { string name = usernameIF.text; string password = passwordIF.text; WWWManager login = new WWWManager(); if (login.CheckNamePassword(name, password)) { hintText.text = "正确"; UserInfo.userName = name; //UserInfo.userInfo.userName = name; Debug.Log(UserInfo.userName); StartCoroutine(LoadScene()); } else { hintText.text = "账号或密码错误!"; StartCoroutine(OkTextDelay()); } } else { hintText.text = "账号或密码为空"; StartCoroutine(OkTextDelay()); Debug.Log("账号或密码为空!"); } }
public void Login() { popup.enabled = true; if (id.text == "") { popupTxt.text = "아이디를 입력해주십시오."; return; } if (pw.text == "") { popupTxt.text = "비밀번호를 입력해주십시오."; return; } popupTxt.text = "로그인중.."; WWWManager wwwManager = WWWManager.getInstance(); int errorCode = wwwManager.DoLogin(id.text, pw.text); if (errorCode == HTTPErrorCode.CONNECTION_ERROR) { popupTxt.text = "서버접속실패!"; } else if (errorCode == HTTPErrorCode.NULL_ERROR) { popupTxt.text = "아이디 또는 비밀번호가 틀렸습니다."; } else if (errorCode == HTTPErrorCode.SUCCESS) { popupTxt.text = "로그인 성공\n로딩중 ..."; wwwManager.GetUserScore(id.text); wwwManager.GetUserItem(id.text); SceneManager.LoadScene("Menu"); } }
public InputField ChatInputField; //Unityで設定 //チャット送信ボタンが押された時の処理 public void PushButtonSendChat() { if (ChatInputField.text == "") { Debug.LogError("chat null"); return; } if (loginDataManager.login_flag == false) { Debug.LogError("Must Login"); return; } WWWForm form = new WWWForm(); form.AddField("user_id", loginDataManager.user_id); //ユーザID form.AddField("play_id", loginDataManager.play_id); //対戦ID //utf-8に変換する string comment = ChatInputField.text; //comment = StringExtensions.ToUtf8(comment); form.AddField("comment", comment, Encoding.GetEncoding("utf-8")); Debug.Log(comment); //発言送信 string url = define.MyServerURL + "chats/chat_post"; WWW www = new WWW(url, form); WWWManager.GetInstance().ConnectWWW(www, ReceiveChat); //入力欄を空にする ChatInputField.text = ""; }
public void IdMultipleCheck(Text id) { if (id.text == "") { checkText.color = Color.red; checkText.text = "ID를 입력해주십시오."; return; } int errorCode = WWWManager.getInstance().IdMultipleCheck(id.text); isSuccess = false; if (errorCode == HTTPErrorCode.SUCCESS) { checkText.color = Color.green; checkText.text = "사용가능한 ID 입니다."; isSuccess = true; } else if (errorCode == HTTPErrorCode.NULL_ERROR) { checkText.color = Color.red; checkText.text = "중복되는 ID입니다."; } else if (errorCode == HTTPErrorCode.CONNECTION_ERROR) { checkText.color = Color.red; checkText.text = "서버접속실패!."; } else { checkText.color = Color.red; checkText.text = "ErrorCode : " + errorCode.ToString(); } }
private IEnumerator DownloadProfileImageCoroutine(string url, OnGetProfilePicture callback, object cookie) { WWW wWW = new WWW(url); WWWManager.Add(wWW); yield return(wWW); if (WWWManager.Remove(wWW)) { string error = wWW.error; if (string.IsNullOrEmpty(error)) { callback(wWW.texture, cookie); } else { Service.Logger.ErrorFormat("Error fetching picture at {0}", new object[] { url }); } wWW.Dispose(); } yield break; }
public void BuyItem(int itemId) { if (!isBuy) { isBuy = true; if (Player.instance.star_point < itemCost[itemId]) { popupCanvas.enabled = true; popupText.text = "별개수가 부족합니다"; } else if (Player.instance.star_point >= itemCost[itemId]) { int errorCode = WWWManager.getInstance().DoBuyItem(Player.instance.user_id, itemId, itemCount[itemId] + 1, itemCost[itemId]); if (errorCode == HTTPErrorCode.CONNECTION_ERROR) { popupCanvas.enabled = true; popupText.text = "서버접속실패!"; } else if (errorCode == HTTPErrorCode.SUCCESS) { itemCount[itemId] += 1; myScoreBoosterPoint.text = itemCount[itemId].ToString(); myStarPoint.text = Player.getInstance().star_point.ToString(); } else { popupCanvas.enabled = true; popupText.text = "구매실패!\nErrorCode : " + errorCode.ToString(); } } isBuy = false; } }
public InputField inputFieldSearchUserName; //検索するユーザ名入力欄 //部屋一覧ボタンが押された時に呼ばれる public void PushGetRoomsButton() { string url = define.MyServerURL + "plays/GetRoom"; WWW www = new WWW(url); WWWManager.GetInstance().ConnectWWW(www, ReceiveRoomDataForJsonData); }
private IEnumerator PullMessages() { string url = this.sessionUrl + this.sessionTimeTag; uint num = this.pullRequestId; WWW wWW = new WWW(url); WWWManager.Add(wWW); yield return(wWW); if (WWWManager.Remove(wWW) && num == this.pullRequestId) { if (wWW.error == null) { this.OnPollFinished(wWW.text); } else if (this.sessionState == ChatSessionState.Connected) { this.OnPollFinished(null); } else { this.ReconnectSession(); Service.Get <StaRTSLogger>().Warn("Unable to pull chat messages. Reconnecting: " + wWW.error); } } wWW.Dispose(); yield break; }
private static WWWManager inst; //インスタンス // Use this for initialization void Start() { if (inst == null) { inst = this; //作成時にインスタンスをスタティック変数に保持 } DontDestroyOnLoad(this.gameObject); }
// Update is called once per frame void Update() { if (isEnded) { isEnded = false; endGamePopup.enabled = true; if (winColor == playerColor) { resultText.text = "WIN"; int score = MatchingInfo.playerScore + 100; if (isUseScoreBooster) { score += 50; } scoreText.text = (score).ToString(); starPointText.text = "10"; WWWManager wwwmanager = WWWManager.getInstance(); wwwmanager.SendScore("Alkkagi", score); wwwmanager.SendScore("Alkkagi", Mathf.Max(0, MatchingInfo.otherScore - 50), MatchingInfo.otherUserId, false); wwwmanager.AddStarPoint(10); } else { int score = Mathf.Max(0, MatchingInfo.playerScore - 50); resultText.text = "LOSE"; scoreText.text = score.ToString(); starPointText.text = "0"; // refresh bool hasGameScore = false; int beforeScore = 0; foreach (UserScore us in UserScore.list) { if (us.game_name == "Alkkagi") { beforeScore = us.score; us.score = score; hasGameScore = true; break; } } Player.instance.total_score += (score - beforeScore); if (!hasGameScore) { Array.Resize <UserScore>(ref UserScore.list, UserScore.list.Length + 1); UserScore.list[UserScore.list.Length - 1] = new UserScore(); UserScore.list[UserScore.list.Length - 1].game_name = "Alkkagi"; UserScore.list[UserScore.list.Length - 1].score = score; } } } }
//ターンが変化していないか調べる関数 void DownloadCheckChengeTurn() { //駒の状態を取得 /plays/対戦ID string url = define.URL + "plays/" + loginDataManager.play_id; WWW www = new WWW(url); WWWManager.GetInstance().ConnectWWW(www, ReceiveGameState); return; }
// 싱글톤 instance object 생성 public static WWWManager getInstance() { if (instance == null) { container = new GameObject(); container.name = "WWWManager"; instance = container.AddComponent(typeof(WWWManager)) as WWWManager; } return(instance); }
//検索ボタンが押された時に呼ばれる public void PushSearchRoomsForUserNameButton() { string url = define.MyServerURL + "plays/SearchRoomForUserName"; WWWForm form = new WWWForm(); string Search_name = inputFieldSearchUserName.text; form.AddField("search_name", Search_name); WWW www = new WWW(url, form); WWWManager.GetInstance().ConnectWWW(www, ReceiveRoomDataForJsonData); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
// Use this for initialization void Start() { Screen.SetResolution(800, 1280, true); popupCanvas.enabled = false; Player player = Player.getInstance(); myScore.text = player.total_score.ToString(); WWWManager wwwManager = WWWManager.getInstance(); string result = wwwManager.GetRank(player.user_id, "total"); if (result == "") { popupCanvas.enabled = true; popupText.text = "서버접속실패!"; return; } Result res = JsonUtility.FromJson <Result>(result); if (res.error == HTTPErrorCode.SUCCESS) { if (res.data != "") { myRank.text = (Int32.Parse(res.data) + 1).ToString(); } } // 랭킹 1-10 GET result = wwwManager.GetAllRank("total"); if (result == "") { popupCanvas.enabled = true; popupText.text = "서버접속실패!"; return; } res = JsonUtility.FromJson <Result>(result); if (res.error == HTTPErrorCode.SUCCESS) { Rank.list = JsonHelper.FromJson <Rank>(res.data); for (int i = 0; i < Rank.list.Length; i++) { id[Rank.list[i].rank - 1].text = Rank.list[i].userId; score[Rank.list[i].rank - 1].text = Rank.list[i].score.ToString(); } } }
void GetChatLog() { if (loginDataManager.play_id == -1) { Debug.LogError("Must Login"); //return; loginDataManager.play_id = 1; loginDataManager.user_id = 1; } string url = define.MyServerURL + "chats/" + loginDataManager.play_id + "/chat_get"; WWW www = new WWW(url); WWWManager.GetInstance().ConnectWWW(www, ReceiveChatLog); }
public void SignUp() { if (!isSignUp) { isSignUp = true; popup.enabled = true; if (!IDMultipleCheck.isSuccess) { popupTxt.text = "중복체크를 하십시오"; return; } if (!PWDCheck.isSuccess) { popupTxt.text = "패스워드가 일치하지않습니다."; return; } if (nameTxt.text == "") { popupTxt.text = "이름을 입력해주십시오"; return; } if (email.text == "") { popupTxt.text = "이메일을 입력해주십시오"; return; } popupTxt.text = "등록중.."; int errorCode = WWWManager.getInstance().DoSignUp(id.text, pwd.text, nameTxt.text, email.text); if (errorCode == HTTPErrorCode.CONNECTION_ERROR) { popup.enabled = true; popupTxt.text = "서버접속실패!"; } else if (errorCode == HTTPErrorCode.SUCCESS) { isSuccess = true; popup.enabled = true; popupTxt.text = "등록성공"; } else { popup.enabled = true; popupTxt.text = "등록실패.\nErrorCode : " + errorCode.ToString(); } } }
void test() { WWWManager www = WWWManager.getInstance(); // GET Test string url = serverIp + "/users/jinwoo"; www.GET(url); // POST Test url = serverIp + "/users/test/rank"; IDictionary <string, string> data = new Dictionary <string, string>(); data.Add("gameName", "단어외우기"); www.POST(url, data); }
// Update is called once per frame void Update() { if (isEnded) { isEnded = false; resultCanvas.enabled = true; scoreText.text = ScoreManager.scorePoint.ToString(); starPointText.text = ScoreManager.starPoint.ToString(); WWWManager wwwManager = WWWManager.getInstance(); if (ScoreManager.maxScore < ScoreManager.scorePoint) { wwwManager.SendScore("Run", ScoreManager.scorePoint); } wwwManager.AddStarPoint(ScoreManager.starPoint); } }
// Update is called once per frame void Update() { if (isEnded) { isEnded = false; popup.enabled = true; score.text = ScoreManagerSnack.score.ToString(); starpoint.text = (ScoreManagerSnack.score / 30).ToString(); WWWManager wwwManager = WWWManager.getInstance(); if (ScoreManagerSnack.maxScore < ScoreManagerSnack.score) { wwwManager.SendScore("Snack", ScoreManagerSnack.score); } wwwManager.AddStarPoint(ScoreManagerSnack.score / 30); } }
//ログインボタンが押された時の処理 public void PushButtonLogin() { if (inputFieldURL.text != null && inputFieldURL.text != string.Empty) { define.ChangeURL(inputFieldURL.text); } //ログイン WWWForm form = new WWWForm(); int room_no = int.Parse(inputFieldRoomNo.text); form.AddField("name", inputFieldName.text); //ユーザ名 form.AddField("room_no", room_no); //部屋番号 //ログイン string url = define.URL + "users/login"; WWW www = new WWW(url, form); WWWManager.GetInstance().ConnectWWW(www, ReceiveLogin); }
private IEnumerator Download(string url) { WWW wWW = new WWW(url); WWWManager.Add(wWW); yield return(wWW); if (WWWManager.Remove(wWW)) { if (!string.IsNullOrEmpty(wWW.error) && wWW.error.StartsWith("Could not resolve host")) { Lang lang = Service.Lang; AlertScreen.ShowModal(true, lang.Get("NO_INTERNET_TITLE", new object[0]), lang.Get("NO_INTERNET", new object[0]), null, null); } wWW.Dispose(); } yield break; }
private IEnumerator ConnectToChannel() { WWW wWW = new WWW(this.channelUrl); WWWManager.Add(wWW); yield return(wWW); if (WWWManager.Remove(wWW) && this.sessionState == ChatSessionState.Connecting) { string error = wWW.error; string text = wWW.text; if (error == null) { this.wwwRetryCount = 0; this.sessionState = ChatSessionState.Connected; this.sessionUrl = ChatSessionUtils.GetSessionUrlFromChannelResponse(text); if (!string.IsNullOrEmpty(this.sessionUrl)) { this.Poll(); } else { Service.Get <StaRTSLogger>().Error("Invalid chat channel response: " + text); } } else { int num = this.wwwRetryCount + 1; this.wwwRetryCount = num; if (num < this.wwwMaxRetry) { this.ReconnectSession(); Service.Get <StaRTSLogger>().Warn("Unable to start chat session. Retrying: " + error); } else { this.sessionState = ChatSessionState.Disconnected; Service.Get <StaRTSLogger>().Warn("Unable to start chat session: " + error); } } } wWW.Dispose(); yield break; }
//ボタンが押された時の処理 public void PushButtonLogout() { if (loginDataManager.login_flag == true && loginDataManager.watcher_flag == false) { //投了 WWWForm form = new WWWForm(); form.AddField("play_id", loginDataManager.play_id); form.AddField("user_id", loginDataManager.user_id); string url = define.URL + "users/logout"; WWW www = new WWW(url, form); //ログアウトしログイン画面に移行 WWWManager.GetInstance().ConnectWWW(www, ReceiveLogout); } else { //ログイン画面へ移行 Application.LoadLevel("login_scene"); return; } }
private IEnumerator RequestManifestFile() { WWW wWW = new WWW(this.manifestUrl); WWWManager.Add(wWW); yield return(wWW); if (!WWWManager.Remove(wWW)) { yield break; } if (wWW.error != null) { this.logger.ErrorFormat("Unable to request manifest file [{0}] on attempt #{1} with the following error: {2}", new object[] { this.manifestUrl, this.loadAttempts, wWW.error }); this.RetryRequest(); } else if (wWW.isDone) { if (wWW.text != "") { this.PrepareManifest(wWW.text); } else { this.logger.ErrorFormat("Manifest request attempt #{0} yielded an empty manifest.", new object[] { this.loadAttempts }); this.RetryRequest(); } } wWW.Dispose(); yield break; }
public void ChangeSceneGame() { for (int i = 0; i < itemToggle.Length; i++) { if (itemToggle[i].isOn) { int errorCode = WWWManager.getInstance().DoItemUse(Player.instance.user_id, i + 1); if (errorCode == HTTPErrorCode.SUCCESS) { ItemUse.isUse[i] = true; } else { ItemUse.isUse[i] = false; } } else { ItemUse.isUse[i] = false; } } SceneManager.LoadScene(game); }
private IEnumerator Query(string url, VideoDataManager.QueryCompleteDelegate onQueryComplete, object callback, object data) { WWW wWW = new WWW(url); WWWManager.Add(wWW); yield return(wWW); if (!WWWManager.Remove(wWW)) { yield break; } string error = wWW.error; if (!string.IsNullOrEmpty(error)) { onQueryComplete(null, callback, data); } else { onQueryComplete(wWW.text, callback, data); } wWW.Dispose(); yield break; }
private IEnumerator Call(WWWForm form, Batch batch) { this.qccCount = 0u; WWW wWW = new WWW(this.url, form.data, this.headers); WWWManager.Add(wWW); yield return(wWW); if (WWWManager.Remove(wWW)) { uint serverTime = Service.ServerAPI.ServerTime; if (string.IsNullOrEmpty(wWW.error)) { string name = "Received batch response"; Service.AssetManager.Profiler.RecordFetchEvent(name, wWW.bytesDownloaded, true, true); object obj = new JsonParser(wWW.text).Parse(); Response response = new Response(); response.FromObject(obj); bool flag = this.responseHandler.MatchProtocolVersion(response.ProtocolVersion); Batch batch2 = null; for (int i = 0; i < batch.Commands.Count; i++) { ICommand command = batch.Commands[i]; Data data = response.DataList[i]; if (data.RequestId != command.Id) { this.logger.Error("RequestId Mismatch in Dispatcher!"); } bool success = this.SuccessStatuses.Contains(data.Status); OnCompleteAction onCompleteAction = command.OnComplete(data, success); if (data.Messages != null) { this.responseHandler.SendMessages(data.Messages); } if (this.qcc.Enabled && this.qcc.StatusWhitelist.Contains(data.Status)) { this.qcc.CorrectBatch(batch, response.DataList, i, new QuietCorrectionController.HandleBatch(this.ReCall)); wWW.Dispose(); if (batch.Sync) { this.syncDispatchLock = false; } goto IL_4DF; } if (onCompleteAction == OnCompleteAction.Desync) { this.responseHandler.Desync(DesyncType.CriticalCommandFail, data.Status); wWW.Dispose(); goto IL_4DF; } if (onCompleteAction == OnCompleteAction.Retry && flag) { command.Tries += 1u; if (command.Tries > 3u) { Service.Logger.Error("Command Desync. " + this.CreateCommandErrorString(command, serverTime)); this.responseHandler.Desync(DesyncType.CommandMaxRetry, data.Status); wWW.Dispose(); goto IL_4DF; } if (batch2 == null) { batch2 = new Batch(); batch2.Sync = batch.Sync; } Service.Logger.Warn("Command Resend. " + this.CreateCommandErrorString(command, serverTime)); command.SetTime(serverTime); batch2.Commands.Add(command); } } if (batch2 != null) { this.Exec(batch2); wWW.Dispose(); goto IL_4DF; } if (batch.Sync) { this.syncDispatchLock = false; this.lastSuccessfulSyncReqestId = this.FindMinMaxCommandId(batch, false); } } else { batch.Tries += 1u; if (batch.Tries > 3u) { Match match = Regex.Match(wWW.error, "\\d+"); uint status = (!match.Success) ? 0u : Convert.ToUInt32(match.Value); Service.Logger.Error("Batch Desync. " + this.CreateBatchErrorString(batch, wWW, serverTime)); this.responseHandler.Desync(DesyncType.BatchMaxRetry, status); wWW.Dispose(); goto IL_4DF; } Service.Logger.Warn("Batch WWW Error. " + this.CreateBatchErrorString(batch, wWW, serverTime)); this.Exec(batch); } wWW.Dispose(); } IL_4DF: yield break; }