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

            _service = new TestService();

            _host.AddService(_service);

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

            _invoker = new BlockingThreadInvoker();
        }
예제 #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();
        }
예제 #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());
        }
예제 #4
0
        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();
        }
예제 #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();
        }
예제 #7
0
        void _service_ServerConnectionFailed(object sender, EventArgs e)
        {
            if (ServerConnectionFailed != null)
            {
                _service = null;
                _host = null;
                ServerConnectionFailed(sender, e);
            }

            LoggedIn = false;
        }
예제 #8
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;
        }
예제 #9
0
 public ClientConsole()
 {
     _host = new ServiceHost();
     _service = new MessageClientService();
 }