public void SendFileTest(string path) { if (!SenderClientA.IsRegistered) { RegisterTest(); } if (SenderClientA.SymmetricEncrypter == null) { GetSessionKeyTest(); } var fileInfo = new FileInfo(path); if (CoreClientB.FilesSending.ContainsKey(fileInfo.Name)) { return; } if (SenderClientB.SymmetricEncrypter == null) { if (SenderClientB.AsymmetricEncrypter == null) { SenderClientB.AuthenticateAsync().Wait(); SenderClientB.GetPublicKeyAsync().Wait(); SenderClientB.SetPublicKey().Wait(); //SenderClientB.GetPublicKeyAsync().Wait(); //SenderClientB.SetPublicKey().Wait(); } SenderClientB.GetSessionKey().Wait(); } if (!SenderClientB.IsAuth) { SenderClientB.AuthenticateAsync().Wait(); } if (!SenderClientB.IsRegistered) { SenderClientB.RegisterAsync().Wait(); } var remoteFileStream = new RemoteFileStreamMole(SenderClientA, fileInfo.Name, fileInfo.Length); remoteFileStream.InitializeAsync().Wait(); Func <object, RecieveOfFileTransferRequestEventArgs, Task> func = (o, args) => { args.AllowContinueRegistration(true, remoteFileStream); return(Task.CompletedTask); }; CoreClientB.RecieveOfFileTransferRequestEvent += func; SenderClientB.SendFileRecieveRequest(fileInfo).Wait(); using (var fileStream = new FileStream(@"C:\MoleFileSavingB\" + fileInfo.Name, FileMode.Create, FileAccess.ReadWrite, FileShare.Read)) { remoteFileStream.CopyToAsync(fileStream).Wait(); } }
public void GetSessionKeyTest() { if (SenderClientA.SymmetricEncrypter != null) { return; } SenderClientA.GetPublicKeyAsync().Wait(); SenderClientA.SetPublicKey().Wait(); SenderClientA.GetSessionKey().Wait(); }
public void GetSessionKeyTest() { if (!SenderClientA.IsAuth) { AuthTest(); } if (SenderClientA.SymmetricEncrypter != null) { return; } try { SenderClientA.GetPublicKeyAsync().Wait(); SenderClientA.SetPublicKey().Wait(); SenderClientA.GetSessionKey().Wait(); } catch (Exception) { SenderClientB.GetPublicKeyAsync().Wait(); //SenderClientA.Inicialize() throw; } }