Exemple #1
0
            public void SimpleRequestTest()
            {
                var poolContainer = Services.GetRequiredService <ISocketClientPoolContainer>();

                Assert.NotNull(poolContainer);
                var client = poolContainer.Get("localhost");

                Assert.NotNull(client);
                Proxy_UserEntryReq req = new Proxy_UserEntryReq()
                {
                    UserId   = 1,
                    UserName = "******"
                };
                var packet = new PacketInfo(1, 0, req.ToByteArray());
                var ret    = client.Send(packet).GetAwaiter().GetResult();

                poolContainer.Return(client);
                Assert.NotNull(ret);
            }
Exemple #2
0
 public Task StartAsync(CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         var client = socketClientPoolContainer.Get("localhost");
         var random = new Random(1);
         for (var i = 0; i < 10000; i++)
         {
             Proxy_UserEntryReq req = new Proxy_UserEntryReq()
             {
                 UserId = random.Next(1, short.MaxValue),
                 UserName = "******"
             };
             var packet = new PacketInfo(1, 1, req.ToByteArray());
             client.SendAsync(packet).GetAwaiter().GetResult();
             logger.LogInformation($"The {req.UserId} send request");
         }
         socketClientPoolContainer.Return(client);
     }));
 }