/// <summary> /// Sends a registration request to given connection /// </summary> public void Register(Dictionary <string, string> data, SuccessCallback callback) { if (!Connection.IsConnected) { callback.Invoke(false, "Not connected to server"); return; } if (_isLoggingIn) { callback.Invoke(false, "Log in is already in progress"); return; } if (IsLoggedIn) { callback.Invoke(false, "Already logged in"); return; } // We first need to get an aes key // so that we can encrypt our login data _securityPlugin.GetAesKey(aesKey => { if (aesKey == null) { callback.Invoke(false, "Failed to register due to security issues"); return; } var encryptedData = Util.EncryptAES(data.ToBytes(), aesKey); Connection.SendMessage((short)OpCodes.RegisterAccount, encryptedData, (status, response) => { if (status != ResponseStatus.Success) { callback.Invoke(false, response.AsString("Unknown error")); return; } callback.Invoke(true, null); Registered?.Invoke(); }); }); }