protected void HandleResponseUserRegister(LiteNetLibMessageHandler messageHandler) { TransportHandler transportHandler = messageHandler.transportHandler; ResponseUserRegisterMessage message = messageHandler.ReadMessage <ResponseUserRegisterMessage>(); transportHandler.ReadResponse(message.ackId, message.responseCode, message); }
public void OnRegister(ResponseHandlerData responseHandler, AckResponseCode responseCode, INetSerializable response) { Registering = false; if (responseCode == AckResponseCode.Timeout) { UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UITextKeys.UI_LABEL_ERROR.ToString()), LanguageManager.GetText(UITextKeys.UI_ERROR_CONNECTION_TIMEOUT.ToString())); if (onRegisterFail != null) { onRegisterFail.Invoke(); } return; } ResponseUserRegisterMessage castedResponse = response as ResponseUserRegisterMessage; switch (responseCode) { case AckResponseCode.Error: string errorMessage = string.Empty; switch (castedResponse.error) { case ResponseUserRegisterMessage.Error.TooShortUsername: errorMessage = LanguageManager.GetText(UITextKeys.UI_ERROR_USERNAME_TOO_SHORT.ToString()); break; case ResponseUserRegisterMessage.Error.TooLongUsername: errorMessage = LanguageManager.GetText(UITextKeys.UI_ERROR_USERNAME_TOO_LONG.ToString()); break; case ResponseUserRegisterMessage.Error.TooShortPassword: errorMessage = LanguageManager.GetText(UITextKeys.UI_ERROR_PASSWORD_TOO_SHORT.ToString()); break; case ResponseUserRegisterMessage.Error.UsernameAlreadyExisted: errorMessage = LanguageManager.GetText(UITextKeys.UI_ERROR_USERNAME_EXISTED.ToString()); break; } UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UITextKeys.UI_LABEL_ERROR.ToString()), errorMessage); if (onRegisterFail != null) { onRegisterFail.Invoke(); } break; default: if (onRegisterSuccess != null) { onRegisterSuccess.Invoke(); } break; } }
public void OnRegister(AckResponseCode responseCode, BaseAckMessage message) { ResponseUserRegisterMessage castedMessage = (ResponseUserRegisterMessage)message; switch (responseCode) { case AckResponseCode.Error: string errorMessage = string.Empty; switch (castedMessage.error) { case ResponseUserRegisterMessage.Error.TooShortUsername: errorMessage = LanguageManager.GetText(UILocaleKeys.UI_ERROR_USERNAME_TOO_SHORT.ToString()); break; case ResponseUserRegisterMessage.Error.TooLongUsername: errorMessage = LanguageManager.GetText(UILocaleKeys.UI_ERROR_USERNAME_TOO_LONG.ToString()); break; case ResponseUserRegisterMessage.Error.TooShortPassword: errorMessage = LanguageManager.GetText(UILocaleKeys.UI_ERROR_PASSWORD_TOO_SHORT.ToString()); break; case ResponseUserRegisterMessage.Error.UsernameAlreadyExisted: errorMessage = LanguageManager.GetText(UILocaleKeys.UI_ERROR_USERNAME_EXISTED.ToString()); break; } UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UILocaleKeys.UI_LABEL_ERROR.ToString()), errorMessage); if (onRegisterFail != null) { onRegisterFail.Invoke(); } break; case AckResponseCode.Timeout: UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UILocaleKeys.UI_LABEL_ERROR.ToString()), LanguageManager.GetText(UILocaleKeys.UI_ERROR_CONNECTION_TIMEOUT.ToString())); if (onRegisterFail != null) { onRegisterFail.Invoke(); } break; default: if (onRegisterSuccess != null) { onRegisterSuccess.Invoke(); } break; } }
public void OnRegister(AckResponseCode responseCode, BaseAckMessage message) { ResponseUserRegisterMessage castedMessage = (ResponseUserRegisterMessage)message; switch (responseCode) { case AckResponseCode.Error: string errorMessage = string.Empty; switch (castedMessage.error) { case ResponseUserRegisterMessage.Error.TooShortUsername: errorMessage = "Username is too short"; break; case ResponseUserRegisterMessage.Error.TooLongUsername: errorMessage = "Username is too long"; break; case ResponseUserRegisterMessage.Error.TooShortPassword: errorMessage = "Password is too short"; break; case ResponseUserRegisterMessage.Error.UsernameAlreadyExisted: errorMessage = "Username is already existed"; break; } UISceneGlobal.Singleton.ShowMessageDialog("Cannot Register", errorMessage); if (onRegisterFail != null) { onRegisterFail.Invoke(); } break; case AckResponseCode.Timeout: UISceneGlobal.Singleton.ShowMessageDialog("Cannot Register", "Connection timeout"); if (onRegisterFail != null) { onRegisterFail.Invoke(); } break; default: if (onRegisterSuccess != null) { onRegisterSuccess.Invoke(); } break; } }
private async UniTaskVoid HandleRequestUserRegisterRoutine(LiteNetLibMessageHandler messageHandler) { long connectionId = messageHandler.connectionId; RequestUserRegisterMessage message = messageHandler.ReadMessage <RequestUserRegisterMessage>(); ResponseUserRegisterMessage.Error error = ResponseUserRegisterMessage.Error.None; string username = message.username; string password = message.password; FindUsernameResp findUsernameResp = await DbServiceClient.FindUsernameAsync(new FindUsernameReq() { Username = username }); if (findUsernameResp.FoundAmount > 0) { error = ResponseUserRegisterMessage.Error.UsernameAlreadyExisted; } else if (string.IsNullOrEmpty(username) || username.Length < minUsernameLength) { error = ResponseUserRegisterMessage.Error.TooShortUsername; } else if (username.Length > maxUsernameLength) { error = ResponseUserRegisterMessage.Error.TooLongUsername; } else if (string.IsNullOrEmpty(password) || password.Length < minPasswordLength) { error = ResponseUserRegisterMessage.Error.TooShortPassword; } else { await DbServiceClient.CreateUserLoginAsync(new CreateUserLoginReq() { Username = username, Password = password }); } ResponseUserRegisterMessage responseMessage = new ResponseUserRegisterMessage(); responseMessage.ackId = message.ackId; responseMessage.responseCode = error == ResponseUserRegisterMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error; responseMessage.error = error; ServerSendResponse(connectionId, MMOMessageTypes.ResponseUserRegister, responseMessage); }
private IEnumerator HandleRequestUserRegisterRoutine(LiteNetLibMessageHandler messageHandler) { long connectionId = messageHandler.connectionId; RequestUserRegisterMessage message = messageHandler.ReadMessage <RequestUserRegisterMessage>(); ResponseUserRegisterMessage.Error error = ResponseUserRegisterMessage.Error.None; string username = message.username; string password = message.password; FindUsernameJob findUsernameJob = new FindUsernameJob(Database, username); findUsernameJob.Start(); yield return(StartCoroutine(findUsernameJob.WaitFor())); if (findUsernameJob.result > 0) { error = ResponseUserRegisterMessage.Error.UsernameAlreadyExisted; } else if (string.IsNullOrEmpty(username) || username.Length < minUsernameLength) { error = ResponseUserRegisterMessage.Error.TooShortUsername; } else if (username.Length > maxUsernameLength) { error = ResponseUserRegisterMessage.Error.TooLongUsername; } else if (string.IsNullOrEmpty(password) || password.Length < minPasswordLength) { error = ResponseUserRegisterMessage.Error.TooShortPassword; } else { CreateUserLoginJob createUserLoginJob = new CreateUserLoginJob(Database, username, password); createUserLoginJob.Start(); yield return(StartCoroutine(createUserLoginJob.WaitFor())); } ResponseUserRegisterMessage responseMessage = new ResponseUserRegisterMessage(); responseMessage.ackId = message.ackId; responseMessage.responseCode = error == ResponseUserRegisterMessage.Error.None ? AckResponseCode.Success : AckResponseCode.Error; responseMessage.error = error; ServerSendPacket(connectionId, DeliveryMethod.ReliableOrdered, MMOMessageTypes.ResponseUserRegister, responseMessage); }
public void OnRegister(ResponseHandlerData responseHandler, AckResponseCode responseCode, ResponseUserRegisterMessage response) { Registering = false; if (responseCode.ShowUnhandledResponseMessageDialog(response.message)) { if (onRegisterFail != null) { onRegisterFail.Invoke(); } return; } if (onRegisterSuccess != null) { onRegisterSuccess.Invoke(); } }