private IEnumerator HandleRequestDeleteCharacterRoutine(LiteNetLibMessageHandler messageHandler) { long connectionId = messageHandler.connectionId; RequestDeleteCharacterMessage message = messageHandler.ReadMessage <RequestDeleteCharacterMessage>(); ResponseDeleteCharacterMessage.Error error = ResponseDeleteCharacterMessage.Error.None; CentralUserPeerInfo userPeerInfo; if (!userPeers.TryGetValue(connectionId, out userPeerInfo)) { error = ResponseDeleteCharacterMessage.Error.NotLoggedin; } else { DeleteCharactersJob job = new DeleteCharactersJob(Database, userPeerInfo.userId, message.characterId); job.Start(); yield return(StartCoroutine(job.WaitFor())); } ResponseDeleteCharacterMessage responseMessage = new ResponseDeleteCharacterMessage(); responseMessage.ackId = message.ackId; responseMessage.responseCode = error == ResponseDeleteCharacterMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error; responseMessage.error = error; ServerSendPacket(connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.ResponseDeleteCharacter, responseMessage); }
protected void HandleResponseDeleteCharacter(LiteNetLibMessageHandler messageHandler) { TransportHandler transportHandler = messageHandler.transportHandler; ResponseDeleteCharacterMessage message = messageHandler.ReadMessage <ResponseDeleteCharacterMessage>(); transportHandler.TriggerAck(message.ackId, message.responseCode, message); }
private void OnRequestedDeleteCharacter(AckResponseCode responseCode, BaseAckMessage message) { ResponseDeleteCharacterMessage castedMessage = (ResponseDeleteCharacterMessage)message; switch (responseCode) { case AckResponseCode.Error: string errorMessage = string.Empty; switch (castedMessage.error) { case ResponseDeleteCharacterMessage.Error.NotLoggedin: errorMessage = LanguageManager.GetText(UILocaleKeys.UI_ERROR_NOT_LOGGED_IN.ToString()); break; } UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UILocaleKeys.UI_LABEL_ERROR.ToString()), errorMessage); break; case AckResponseCode.Timeout: UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UILocaleKeys.UI_LABEL_ERROR.ToString()), LanguageManager.GetText(UILocaleKeys.UI_ERROR_CONNECTION_TIMEOUT.ToString())); break; default: // Reload characters LoadCharacters(); break; } }
private void OnRequestedDeleteCharacter(ResponseHandlerData responseHandler, AckResponseCode responseCode, INetSerializable response) { if (responseCode == AckResponseCode.Timeout) { UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UITextKeys.UI_LABEL_ERROR.ToString()), LanguageManager.GetText(UITextKeys.UI_ERROR_CONNECTION_TIMEOUT.ToString())); return; } // Proceed response ResponseDeleteCharacterMessage message = response as ResponseDeleteCharacterMessage; switch (responseCode) { case AckResponseCode.Error: string errorMessage = string.Empty; switch (message.error) { case ResponseDeleteCharacterMessage.Error.NotLoggedin: errorMessage = LanguageManager.GetText(UITextKeys.UI_ERROR_NOT_LOGGED_IN.ToString()); break; } UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UITextKeys.UI_LABEL_ERROR.ToString()), errorMessage); break; default: // Reload characters LoadCharacters(); break; } }
private void OnRequestedDeleteCharacter(AckResponseCode responseCode, BaseAckMessage message) { ResponseDeleteCharacterMessage castedMessage = (ResponseDeleteCharacterMessage)message; switch (responseCode) { case AckResponseCode.Error: string errorMessage = string.Empty; switch (castedMessage.error) { case ResponseDeleteCharacterMessage.Error.NotLoggedin: errorMessage = "User not logged in"; break; } UISceneGlobal.Singleton.ShowMessageDialog("Cannot Delete Character", errorMessage); break; case AckResponseCode.Timeout: UISceneGlobal.Singleton.ShowMessageDialog("Cannot Delete Character", "Connection timeout"); break; default: // Reload characters LoadCharacters(); break; } }
private async UniTaskVoid HandleRequestDeleteCharacterRoutine(LiteNetLibMessageHandler messageHandler) { long connectionId = messageHandler.connectionId; RequestDeleteCharacterMessage message = messageHandler.ReadMessage <RequestDeleteCharacterMessage>(); ResponseDeleteCharacterMessage.Error error = ResponseDeleteCharacterMessage.Error.None; CentralUserPeerInfo userPeerInfo; if (!userPeers.TryGetValue(connectionId, out userPeerInfo)) { error = ResponseDeleteCharacterMessage.Error.NotLoggedin; } else { await DbServiceClient.DeleteCharacterAsync(new DeleteCharacterReq() { UserId = userPeerInfo.userId, CharacterId = message.characterId }); } ResponseDeleteCharacterMessage responseMessage = new ResponseDeleteCharacterMessage(); responseMessage.ackId = message.ackId; responseMessage.responseCode = error == ResponseDeleteCharacterMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error; responseMessage.error = error; ServerSendResponse(connectionId, MMOMessageTypes.ResponseDeleteCharacter, responseMessage); }
private void OnRequestedDeleteCharacter(ResponseHandlerData responseHandler, AckResponseCode responseCode, ResponseDeleteCharacterMessage response) { if (responseCode.ShowUnhandledResponseMessageDialog(response.message)) { return; } // Reload characters LoadCharacters(); }
private async UniTaskVoid OnRequestedDeleteCharacter(ResponseHandlerData responseHandler, AckResponseCode responseCode, ResponseDeleteCharacterMessage response) { await UniTask.Yield(); if (responseCode.ShowUnhandledResponseMessageDialog(response.message)) { return; } // Reload characters LoadCharacters(); }