Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            #if DEBUG
            Visibility = Visibility.Visible;
            #endif

            // Set up IPC server.
            try
            {
                _channel = new IpcServerChannel( "ChromeAbcConnection" );
            }
            catch ( RemotingException )
            {
                // A previous server channel is still running.
                Application.Current.Shutdown();

                return;
            }

            // Set up messaging with Chrome.
            WriteOutput( "Starting up standard input/output communication with Chrome." );
            var messaging = new ChromeMessaging( Console.OpenStandardInput(),  Console.OpenStandardOutput() );
            messaging.MessageReceived += OnMessageReceived;

            // Shut down application if no keep alive message has been received.
            _isConnectedTimer.Elapsed += ( sender, args ) =>
            {
                if ( !_isAlive )
                {
                    Dispatcher.Invoke( () => Application.Current.Shutdown() );
                }

                _isAlive = false;
            };
            _isConnectedTimer.Start();

            // Setup up channel for the Chrome ABC plugin to communicate with.
            ChannelServices.RegisterChannel( _channel, false );
            var chromeService = new ChromeAbcService( messaging );
            RemotingServices.Marshal( chromeService, "ChromeAbcService" );
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();

#if DEBUG
            Visibility = Visibility.Visible;
#endif

            // Set up IPC server.
            try
            {
                _channel = new IpcServerChannel("ChromeAbcConnection");
            }
            catch (RemotingException)
            {
                // A previous server channel is still running.
                Application.Current.Shutdown();

                return;
            }

            // Set up messaging with Chrome.
            WriteOutput("Starting up standard input/output communication with Chrome.");
            var messaging = new ChromeMessaging(Console.OpenStandardInput(), Console.OpenStandardOutput());
            messaging.MessageReceived += OnMessageReceived;

            // Shut down application if no keep alive message has been received.
            _isConnectedTimer.Elapsed += (sender, args) =>
            {
                if (!_isAlive)
                {
                    Dispatcher.Invoke(() => Application.Current.Shutdown());
                }

                _isAlive = false;
            };
            _isConnectedTimer.Start();

            // Setup up channel for the Chrome ABC plugin to communicate with.
            ChannelServices.RegisterChannel(_channel, false);
            var chromeService = new ChromeAbcService(messaging);
            RemotingServices.Marshal(chromeService, "ChromeAbcService");
        }