Beispiel #1
0
        static void Main(string[] args)
        {
            var logger = new Logger(logLevel: LogLevel.Debug);
            var stats  = new Stats();

            var addr = new[] { "127.0.0.1", "8098" }; //defaults

            if (null != args && args.Length > 0)
            {
                var parts = args[0].Split(':');
                if (parts.Length > 1)
                {
                    addr[1] = parts[1];
                }
                addr[0] = parts[0];
            }

            var ip         = addr[0];
            var port       = Convert.ToInt32(addr[1]);
            var ipEndpoint = new IPEndPoint(IPAddress.Any, port);

            var useCompression       = false;
            var compressionThreshold = 131072; //128KB
            var zkRepository         = new DemoZkRepository();

            var tcphost = new TcpHost(ipEndpoint, logger, stats, zkRepository);

            tcphost.UseCompression       = useCompression;
            tcphost.CompressionThreshold = compressionThreshold;

            var simpleContract = new DataContractImpl();

            tcphost.AddService <IDataContract>(simpleContract);

            var complexContract = new ComplexDataContractImpl();

            tcphost.AddService <IComplexDataContract>(complexContract);

            var test = new Test();

            tcphost.AddService <ITest>(test);

            tcphost.Open();

            Console.WriteLine("Press Enter to stop the dual host test.");
            Console.ReadLine();

            tcphost.Close();

            Console.WriteLine("Press Enter to quit.");
            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var logger = new Logger(logLevel: LogLevel.Debug);
            var stats  = new Stats();

            var ip         = ConfigurationManager.AppSettings["ip"];
            var port       = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
            var ipEndpoint = new IPEndPoint(IPAddress.Any, port);

            var useCompression       = false;
            var compressionThreshold = 131072; //128KB
            var pipeName             = "ServiceWireTestHost";

            var nphost = new NpHost(pipeName, logger, stats);
            var tester = new NetTester();

            nphost.AddService <INetTester>(tester);
            var mytester = new MyTester();

            nphost.UseCompression       = useCompression;
            nphost.CompressionThreshold = compressionThreshold;
            nphost.AddService <IMyTester>(mytester);
            nphost.Open();

            var tcphost = new TcpHost(ipEndpoint, logger, stats);

            tcphost.UseCompression       = useCompression;
            tcphost.CompressionThreshold = compressionThreshold;
            tcphost.AddService <INetTester>(tester);
            tcphost.AddService <IMyTester>(mytester);

            var valTypes = new ValTypes();

            tcphost.AddService <IValTypes>(valTypes);

            tcphost.Open();

            Console.WriteLine("Press Enter to stop the dual host test.");
            Console.ReadLine();

            nphost.Close();
            tcphost.Close();

            Console.WriteLine("Press Enter to quit.");
            Console.ReadLine();
        }
Beispiel #3
0
        public TcpZkTests()
        {
            _tester    = new NetTester();
            _ipAddress = IPAddress.Parse("127.0.0.1");

            _tcphost = new TcpHost(CreateEndPoint(), zkRepository: _repo);
            _tcphost.AddService <INetTester>(_tester);
            _tcphost.Open();
        }
        public void Configure(MiNetServer server)
        {
            var logger = new Logger(logLevel: LogLevel.Debug);
            var stats  = new Stats();

            _levelService = new LevelService(server);

            _server = new TcpHost(new IPEndPoint(IPAddress.Any, 19137), logger, stats);
            _server.AddService <ILevelService>(_levelService);
            _server.Open();
            Log.InfoFormat("Dev Tools LevelService Started");
        }
Beispiel #5
0
        public void RunHost()
        {
            _tester = new Mock <INetTester>();

            _tester
            .Setup(o => o.Min(It.IsAny <int>(), It.IsAny <int>()))
            .Returns((int a, int b) => Math.Min(a, b));

            _tester
            .Setup(o => o.Range(It.IsAny <int>(), It.IsAny <int>()))
            .Returns((int a, int b) => Enumerable.Range(a, b).ToDictionary(key => key, el => el));

            _ipAddress = IPAddress.Parse("127.0.0.1");

            _tcphost = new TcpHost(CreateEndPoint(), zkRepository: _repo);
            _tcphost.AddService <INetTester>(_tester.Object);
            _tcphost.Open();
        }
Beispiel #6
0
        public Host(IPEndPoint endPoint,
                    string packageStorageDirectory = null, string sessionExecutionDirectory = null, bool runLocalInProcess = false)
        {
            var rootDir = AppDomain.CurrentDomain.BaseDirectory;

            if (null == packageStorageDirectory)
            {
                packageStorageDirectory = Path.Combine(rootDir, @"_dpack");
                Directory.CreateDirectory(packageStorageDirectory);
            }
            if (null == sessionExecutionDirectory)
            {
                sessionExecutionDirectory = Path.Combine(rootDir, @"_dexec");
                Directory.CreateDirectory(sessionExecutionDirectory);
            }

            //must include some info about this host
            _serviceHost = new ServiceHost(endPoint, packageStorageDirectory, sessionExecutionDirectory, runLocalInProcess);
            _tcpHost     = new TcpHost(endPoint);
            _tcpHost.AddService <IServiceHost>(_serviceHost);
            _tcpHost.Open();
        }