Exemple #1
0
 protected override Task RunInternal()
 {
     return(Task.Run(async() =>
     {
         SocketSettings settings = new SocketSettings
         {
             CatchApplicationExceptions = false,
             RsaXmlKey = Library.PublicKey
         };
         LocalClient local = new LocalClient();
         VSLClient client = new VSLClient(settings, local);
         await client.ConnectAsync("::1", Library.Port);
         running = true;
         stopwatch.Start();
         async Task inner()
         {
             while (running && Done < Total)
             {
                 byte[] buf = new byte[random.Next(2048)];
                 random.NextBytes(buf);
                 if (await client.SendPacketAsync(0, buf))
                 {
                     Interlocked.Increment(ref Done);
                 }
                 else
                 {
                     running = false;
                 }
             }
         }
         await Task.WhenAll(Enumerable.Range(0, 4).Select(x => inner()));
     }));
 }
Exemple #2
0
 private async void BtnConnect_Click(object sender, EventArgs e)
 {
     if (!clientConnected)
     {
         btnConnect.Enabled = false;
         SocketSettings settings = new SocketSettings()
         {
             CatchApplicationExceptions = false,
             RsaXmlKey = Library.PublicKey
         };
         new VSLClient(settings, this);
         var progress = new Progress <VSLClient.ConnectionState>((state) => Console.WriteLine(state));
         await vslClient.ConnectAsync("localhost", Library.Port, progress);
     }
     else
     {
         vslClient.CloseConnection("The user requested to disconnect", null);
     }
 }