Example #1
0
        /**
         * This method binding the service
         */
        private Boolean bindProxyService()
        {
            Debug.Print("Binding proxy service...");
            try
            {
                WS2007HttpBinding a = new WS2007HttpBinding();
                ProtocolVersion11 b = new ProtocolVersion11();
                proxy = new IService1ClientProxy(a, b);

                // NOTE: the endpoint needs to match the endpoint of the servicehost
                proxy.EndpointAddress = SERVICE_ADDR;
            }
            catch (SocketException e)
            {
                WindowsManager.showWindowServiceDown();
                return(false);
            }
            catch (ObjectDisposedException e)
            {
                Debug.Print("Disposed object exception");
                WindowsManager.showWindowServiceDown();
                return(false);
            }


            Debug.Print("Binding proxy service COMPLETE");
            return(true);
        }
Example #2
0
        /**
         * This method is triggered when the network goes down.
         * It triggers the alarm.
         */
        private void OnNetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network down!");
            NetworkUp = false;
            multicolorLED.TurnRed();
            if (proxy != null)
            {
                proxy.closeChannel();
                proxy.Dispose();
                proxy.Dispose();
                proxy = null;
            }

            if (streaming)
            {
                streaming = false;
                camera.StopStreaming();
                button.ButtonPressed -= button_ButtonPressed;
                if (timer_joystick.IsRunning)
                {
                    timer_joystick.Stop();
                }
            }

            if (setupComplete)
            {
                timer_keepAlive.Stop();
                if (!throw_allarm)
                {
                    ThrowAllarm();
                }
                WindowsManager.showWindowInsertPin();
            }
            else
            {
                camera.StopStreaming();
                Thread.Sleep(250);
                WindowsManager.showWindowNetworkDown();
                return;
            }
        }