Beispiel #1
0
 public MessageService(IBinarySerializer binarySerializer)
 {
     _remotingClient = new SocketRemotingClient(Settings.BrokerAddress, Settings.BrokerPort);
     _remotingClient.Connect();
     _remotingClient.Start();
     _binarySerializer = binarySerializer;
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            ECommonConfiguration
                .Create()
                .UseAutofac()
                .RegisterCommonComponents()
                .UseLog4Net()
                .RegisterUnhandledExceptionHandler();

            _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(typeof(Program).Name);

            var serverIP = ConfigurationManager.AppSettings["ServerAddress"];
            var mode = ConfigurationManager.AppSettings["Mode"];
            var serverAddress = string.IsNullOrEmpty(serverIP) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(serverIP);
            var parallelThreadCount = int.Parse(ConfigurationManager.AppSettings["ClientCount"]);
            var messageSize = int.Parse(ConfigurationManager.AppSettings["MessageSize"]);
            var messageCount = int.Parse(ConfigurationManager.AppSettings["MessageCount"]);
            var sleepMilliseconds = int.Parse(ConfigurationManager.AppSettings["SleepMilliseconds"]);
            var batchSize = int.Parse(ConfigurationManager.AppSettings["BatchSize"]);
            var message = new byte[messageSize];
            var actions = new List<Action>();

            for (var i = 0; i < parallelThreadCount; i++)
            {
                var client = new SocketRemotingClient(new IPEndPoint(serverAddress, 5000));
                client.Start();
                actions.Add(() => SendMessages(client, mode, messageCount, sleepMilliseconds, batchSize, message));
            }

            _watch.Start();
            Parallel.Invoke(actions.ToArray());
            Console.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var maxSendPacketSize = int.Parse(ConfigurationManager.AppSettings["MaxSendPacketSize"]);
            var socketBufferSize = int.Parse(ConfigurationManager.AppSettings["SocketBufferSize"]);
            var setting = new Setting
            {
                TcpConfiguration = new TcpConfiguration
                {
                    MaxSendPacketSize = maxSendPacketSize,
                    SocketBufferSize = socketBufferSize
                }
            };
            ECommonConfiguration
                .Create(setting)
                .UseAutofac()
                .RegisterCommonComponents()
                .UseLog4Net()
                .RegisterUnhandledExceptionHandler();

            var serverIP = ConfigurationManager.AppSettings["ServerAddress"];
            var mode = ConfigurationManager.AppSettings["Mode"];
            var ipAddress = string.IsNullOrEmpty(serverIP) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(serverIP);
            _remotingClient = new SocketRemotingClient(new IPEndPoint(ipAddress, 5000));
            _remotingClient.Start();

            var parallelThreadCount = int.Parse(ConfigurationManager.AppSettings["ParallelThreadCount"]);
            var actions = new List<Action>();
            for (var i = 0; i < parallelThreadCount; i++)
            {
                actions.Add(() => SendMessageAsync(mode));
            }

            _watch.Start();
            Parallel.Invoke(actions.ToArray());
            Console.ReadLine();
        }
Beispiel #4
0
        static void SendMessageTest()
        {
            _mode = ConfigurationManager.AppSettings["Mode"];

            var serverIP = ConfigurationManager.AppSettings["ServerAddress"];
            var serverAddress = string.IsNullOrEmpty(serverIP) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(serverIP);
            var clientCount = int.Parse(ConfigurationManager.AppSettings["ClientCount"]);
            var messageSize = int.Parse(ConfigurationManager.AppSettings["MessageSize"]);
            var messageCount = int.Parse(ConfigurationManager.AppSettings["MessageCount"]);
            var sleepMilliseconds = int.Parse(ConfigurationManager.AppSettings["SleepMilliseconds"]);
            var batchSize = int.Parse(ConfigurationManager.AppSettings["BatchSize"]);
            var message = new byte[messageSize];
            var actions = new List<Action>();

            for (var i = 1; i <= clientCount; i++)
            {
                var client = new SocketRemotingClient("Client" + i.ToString(), new IPEndPoint(serverAddress, 5000));
                client.Start();
                actions.Add(() => SendMessages(client, _mode, messageCount, sleepMilliseconds, batchSize, message));
            }

            Parallel.Invoke(actions.ToArray());
        }