Example #1
0
        public void Attack()
        {
            Task.Run(() =>
            {
                Thread.Sleep(300);
                using (ISocketClientConnection connection = SocketConnectionFactory.GetConnection())
                {
                    for (int i = 0; i < TotalFired; i++)
                    {
                        try
                        {
                            connection.SendRequest("CustomerController", "AddCustomer", new
                            {
                                customer = $"Customer n {i + 1} of attacker #{AttackerId}"
                            });

                            if (connection.GetResult().Status == 600)
                            {
                                RequestsSuccess += 1;
                            }
                            else
                            {
                                RequestFails += 1;
                            }
                        }
                        catch
                        {
                            RequestFails += 1;
                        }
                    }

                    manager.EndBatch(TotalFired, RequestsSuccess, RequestFails);
                }
            });
        }
Example #2
0
        static void Main()
        {
            SocketConnectionFactory.SetDefaultSettings(new SocketClientSettings
                                                       (
                                                           "localhost",
                                                           2500,
                                                           Encoding.UTF8
                                                       ));

            using (ISocketClientConnection connection = SocketConnectionFactory.GetConnection())
            {
                connection.SendRequest("controller", "action", new
                {
                    nome  = "XPTO",
                    idade = 39,
                    outroParametroQualquer = Guid.NewGuid()
                });

                var response = connection.ReadResponse();
            }



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        private ISocketClientConnection GetClient()
        {
            IServiceManager manager = ServiceManager.GetInstance();

            logging = manager.GetService <ILoggingService>();

            ICoreServerService      coreServer = manager.GetService <ICoreServerService>();
            ServerConfiguration     config     = coreServer.GetConfiguration();
            ISocketClientConnection connection = SocketConnectionFactory
                                                 .GetConnection(new SocketClientSettings("localhost", config.Port, config.ServerEncoding));

            return(connection);
        }
Example #4
0
 private ISocketClientConnection BuildClient(SubServer server)
 {
     try
     {
         return(SocketConnectionFactory.GetConnection(new SocketClientSettings(
                                                          server: server.Address,
                                                          port: server.Port,
                                                          encoding: server.Encoding,
                                                          maxAttempts: server.MaxConnectionAttempts
                                                          )));
     }
     catch (Exception ex)
     {
         Logger.WriteLog($"Fail to connect server {server.Address}:{server.Port} : {ex.Message}", ServerLogType.ERROR);
         return(null);
     }
 }
Example #5
0
        static void Main(string[] args)
        {
            try
            {
                SocketConnectionFactory.SetDefaultSettings(new SocketClientSettings(
                                                               "localhost", 7001,
                                                               Encoding.UTF8, 3
                                                               ));

                using (ISocketClientConnection conn = SocketConnectionFactory.GetConnection())
                {
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
            }
        }