Beispiel #1
0
        public void SetUp()
        {
            _host = new ServiceHost();

            _service = new TestService();

            _host.AddService(_service);

            _host.StartServiceHost();
            _host.OpenServices();

            _invoker = new BlockingThreadInvoker();
        }
Beispiel #2
0
        private static void StartService()
        {
            ServiceHost host = new ServiceHost();

            host.AddService(new HelloWorldService());

            host.StartServiceHost();
            host.OpenServices();

            Console.WriteLine("Press enter to stop server");
            Console.ReadLine();

            host.CloseServices();
            host.StopServiceHost();
        }
Beispiel #3
0
        public void SetUp()
        {
            _host = new ServiceHost();

            _service = new RemotingTestService();

            _host.AddService(_service);

            _host.StartServiceHost();
            _host.OpenServices();

            _invoker = new BlockingThreadInvoker();

            IRemotingTestServices services = _service.GetServices(_invoker);

            _connection = _invoker.WaitOn(services.Connect());
        }
        public void TestQueue()
        {
            ServiceHost host = new ServiceHost();

            InvokeQueueTestService testService = new InvokeQueueTestService();

            host.AddService(testService);

            host.StartServiceHost();
            host.OpenServices();

            using (ManualResetEvent callbackEvent = new ManualResetEvent(false))
            {
                object state = new object();

                IAsyncResult resultFromCallback;
                object stateFromCallback;
                bool callbackWorked = false;

                IInvokeQueueTestInterface testInterface = testService.GetTestInterface(null);

                /*
                Hmm, blocking from deferreds is a bit tricky.

                Deferred<int> result = testInterface.GetReactorThreadId(false);

                int reactorThreadId = testService.EndGetReactorThreadId(result);

                Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, reactorThreadId);
                Assert.AreNotEqual(0, reactorThreadId);
                */

                bool callbackCompleted = callbackEvent.WaitOne(2000, false);

                Assert.IsTrue(callbackCompleted);
                Assert.IsTrue(callbackWorked);
            }

            host.StopServiceHost();
        }
Beispiel #5
0
        private static void StartChatRoomServer(ChatroomSettings settings)
        {
            ServiceHost host = new ServiceHost();

            host.AddService(new ChatroomService(settings));

            host.StartServiceHost();
            host.OpenServices();

            Console.WriteLine("Type \"quit\" to shut down server");

            string input = null;

            do
            {
                input = Console.ReadLine();
                Console.WriteLine(input);
                //TODO: Implement Console Commands
            }
            while (input != "quit");

            host.CloseServices();
            host.StopServiceHost();
        }
        protected override void OnServiceOpen(IServiceHost host)
        {
            _rebuilderService = new FileRebuilderService(Settings);

            _host = new ServiceHost();

            _host.AddService(_rebuilderService);

            _host.StartServiceHost();
            _host.OpenServices();
        }
Beispiel #7
0
        internal void StartHost()
        {
            if (_service != null) return;

            _host = new ServiceHost();

            _service = new ChatroomClientService(TermReceived);

            _service.ServerConnectionFailed += new EventHandler(_service_ServerConnectionFailed);

            _host.AddService(_service);

            _host.StartServiceHost();

            _host.OpenServices();

            _hostStarted = true;
        }