public void HandleErrorResponse(ConnectionHandler.RequestResult result, string response) { Debug.Log("GameConnector.HandleErrorResponse (result=" + result + ")\nresponse: " + response); string title = ""; string message = ""; switch (result) { case (ConnectionHandler.RequestResult.NoInternet): title = "Connection Error"; message = "Unable to connect with server. Check you internet connection and try again"; break; case (ConnectionHandler.RequestResult.CantReachServer): title = "Server under maintenance"; message = "Server is under maintenance. Please try again in 1 hour."; break; case (ConnectionHandler.RequestResult.InternalServerError): break; case (ConnectionHandler.RequestResult.OkWithErrorInside): JsonData responseErrorJsonOnject = JsonMapper.ToObject(response); JsonData errorObject = (JsonData)responseErrorJsonOnject [keyError]; ServerErrorData error = JsonMapper.ToObject <ServerErrorData> (errorObject.ToJson()); Debug.Log("Handling server error message: " + error.ToString()); if (error.code == (int)ConnectionHandler.RequestResult.ClientUpdateRequired) { title = error.title; message = "You must update your game - update initiated (url=" + error.message + ")."; break; } title = "Server under maintenance"; message = "Server is under maintenance. Please try again in 1 hour."; break; } ShowDialog(title, message); }
public void HandleErrorResponse(ConnectionHandler.RequestResult result, string response) { logger.Log(Tag.Italics(), "ModelSync.HandleErrorResponse (result=" + result + ")\nresponse: " + response.SSubstring(200)); string title = ""; string message = ""; string button = ""; bool showDialog = false; bool recoverUnidentifiedUSer = false; switch (result) { case (ConnectionHandler.RequestResult.NoInternet): _flowDisconnectReason = FlowDisconnectReason.NoInternet; title = "Connection Error"; message = "Unable to connect with server. Check you internet connection and try again"; button = "Try Again"; break; case (ConnectionHandler.RequestResult.CantReachServer): title = "Connection Error"; message = "Unable to connect with server. Please try again"; button = "Try Again"; _flowDisconnectReason = FlowDisconnectReason.CantReachServer; break; case (ConnectionHandler.RequestResult.InternalServerError): _flowDisconnectReason = FlowDisconnectReason.ServerInternalError; break; case (ConnectionHandler.RequestResult.UnAuthorized): title = "Progress Detected"; message = "You have been playing on another device. Please reload game to load your progress"; button = "Reload"; _flowDisconnectReason = FlowDisconnectReason.ExpiredToken; break; case (ConnectionHandler.RequestResult.OkWithErrorInside): JsonData responseErrorJsonOnject = JsonMapper.ToObject(response); JsonData errorObject = (JsonData)responseErrorJsonOnject [keyError]; ServerErrorData error = JsonMapper.ToObject <ServerErrorData> (errorObject.ToJson()); logger.Log(Tag, "Handling server error message: " + error.ToString()); if (error.code == (int)ConnectionHandler.RequestResult.UnAuthorized) { _flowDisconnectReason = FlowDisconnectReason.ExpiredToken; title = "Progress Detected"; message = "You have been playing on another device. Please reload game to load your progress"; button = "Reload"; break; } if (error.code == (int)ConnectionHandler.RequestResult.ClientUpdateRequired) { _flowDisconnectReason = FlowDisconnectReason.ClientUpdateStarted; title = error.title; message = "You must update your game - update initiated (url=" + error.message + ")."; button = ""; break; } if (error.code == (int)ConnectionHandler.RequestResult.InternalServerError && error.message == "User not foundPlayer not found") { logger.Log(Tag, "ModelSync.HandleErrorResponse() - PlayerId not found on server => staring new game"); recoverUnidentifiedUSer = true; //_gameDB.SaveSyncInfo(keyPlayerId, "0"); TTPlayerPrefs.SetValue(keyPlayerId, "0"); _gameDB.SaveSyncInfo(keyLastStateUpdate, ""); RestartFlowAfterUserSwitch(); } title = "Unidentified Server Error"; message = "error " + error.ToString(); button = "reload"; break; } if (!recoverUnidentifiedUSer) { _syncState = SyncLoopState.DisconnectedOnHold; } if (connectionDisconnectedSignal != null) { connectionDisconnectedSignal.Dispatch(_flowDisconnectReason); } if (showDialog) { ShowErrorDialog(title, message, button); } }