Beispiel #1
0
        public void Connect()
        {
            var endpoint = $"http://{Config.ServerHost}:{Config.ServerPort}/";

            Console.WriteLine($"Connecting to {endpoint}");

            _connection = new HubConnection(endpoint);

            _proxy = _connection.CreateHubProxy("CameraHub");

            _connection.Start().ContinueWith(task => {
                if (task.IsFaulted)
                {
                    Console.WriteLine("There was an error opening the connection:{0}", task.Exception.GetBaseException());
                }
                else
                {
                    Console.WriteLine("Connected");
                    _connected = true;
                }
            }).Wait();


            InformIp();

            _proxy.On <ProcessingMode>("setMode", param => { SetMode?.Invoke(this, param); });

            _proxy.On <PanTiltSettingCommand>("panTiltCommand", s => PanTiltCommand?.Invoke(this, s));

            _proxy.On <PiSettings>("updateSettings", settings => SettingsChanged?.Invoke(this, settings));

            _proxy.On <Rectangle>("setRegionOfInterest", r => SetRegionOfInterest?.Invoke(this, r));

            _proxy.On <CaptureConfig>("updateCapture", c => UpdateCapture?.Invoke(this, c));
        }
        public void Connect()
        {
            if (_connection != null)
            {
                _connection.Dispose();
            }

            if (!Config.IsValid)
            {
                Log("Bad config - environment variables expected- see Web.Client.Config.cs");
                return;
            }
            var endpoint = $"http://{Config.ServerHost}:{Config.ServerPort}/";

            Log($"Connecting to {endpoint}");

            _connection = new HubConnection(endpoint);

            _connection.Error          += _connection_Error;
            _connection.Closed         += _connection_Closed;
            _connection.StateChanged   += _connection_StateChanged;
            _connection.ConnectionSlow += _connection_ConnectionSlow;

            _proxy = _connection.CreateHubProxy("CameraHub");

            _connection.Start().ContinueWith(task => {
                if (task.IsFaulted)
                {
                    Log($"There was an error opening the connection:{task.Exception.GetBaseException()}");
                }
                else
                {
                    Log("Connected");
                    _connected = true;
                }
            }).Wait();


            InformIp();

            _proxy.On <ProcessingMode>("setMode", param => { SetMode?.Invoke(this, param); });

            _proxy.On <PanTiltSettingCommand>("panTiltCommand", s => PanTiltCommand?.Invoke(this, s));

            _proxy.On <PiSettings>("updateSettings", settings => SettingsChanged?.Invoke(this, settings));

            _proxy.On <Rectangle>("setRegionOfInterest", r => SetRegionOfInterest?.Invoke(this, r));

            _proxy.On <CaptureConfig>("updateCapture", c => UpdateCapture?.Invoke(this, c));
        }
Beispiel #3
0
 public void InvokeUpdateCapture(CaptureConfig captureConfig)
 {
     UpdateCapture?.Invoke(this, captureConfig);
 }