public void OnSignedUp(OnSignedUpRequest userSignedUp) { ContactStateManager.AddNewSignedContact(new UserDTO { UserName = userSignedUp.UserName }); OnSignedUpEvent?.Invoke(this, new OnSignedUpEventArgs { UserName = userSignedUp.UserName }); }
/// <summary> /// Sends a registration request to given connection /// </summary> public void SignUp(MstProperties data, SuccessCallback callback, IClientSocket connection) { if (IsNowSigningIn) { callback.Invoke(false, "Signing in is already in progress"); return; } if (IsSignedIn) { callback.Invoke(false, "Already signed in"); return; } if (!connection.IsConnected) { callback.Invoke(false, "Not connected to server"); return; } // We first need to get an aes key // so that we can encrypt our login data Mst.Security.GetAesKey(aesKey => { if (aesKey == null) { callback.Invoke(false, "Failed to register due to security issues"); return; } var encryptedData = Mst.Security.EncryptAES(data.ToBytes(), aesKey); connection.SendMessage((short)MstMessageCodes.SignUp, encryptedData, (status, response) => { if (status != ResponseStatus.Success) { callback.Invoke(false, response.AsString("Unknown error")); return; } callback.Invoke(true, null); OnSignedUpEvent?.Invoke(); }); }, connection); }