Esempio n. 1
0
        private void updateAvailableVehicles()
        {
            ConcurrentDictionary <int, ClientVehicleDto> res = new ConcurrentDictionary <int, ClientVehicleDto>();
            GetObjectListRequest request = new GetObjectListRequest()
            {
                ClientId            = _connectionService.GetClientId(),
                ObjectType          = INVARIANT_ENTITY_NAME,
                RefreshDependencies = true,
            };

            request.RefreshExcludes.Add("PayloadProfile");
            request.RefreshExcludes.Add("Route");
            request.RefreshExcludes.Add("Mission");
            request.RefreshExcludes.Add("Platform");

            var response = _connectionService.Execute <GetObjectListResponse>(request);

            foreach (var vehicles in response.Objects)
            {
                res.TryAdd(vehicles.Vehicle.Id, new ClientVehicleDto()
                {
                    VehicleId = vehicles.Vehicle.Id,
                    Name      = vehicles.Vehicle.Name
                });
            }
            Vehicles = res;
        }
Esempio n. 2
0
        public void SubscribeTelemtry(Action <int, TelemetryKey, TelemetryValue> cb)
        {
            _tlmCallBack = cb;
            _eventSubscriptionWrapper.TelemetryBatchSubscription = new TelemetryBatchSubscription()
            {
                PollingPeriodMilliseconds          = POLLING_INTERVAL,
                PollingPeriodMillisecondsSpecified = true
            };

            SubscribeEventRequest requestEvent = new SubscribeEventRequest
            {
                ClientId = _connectionService.GetClientId(),

                Subscription = _eventSubscriptionWrapper
            };
            var responce = _connectionService.Submit <SubscribeEventResponse>(requestEvent);

            if (responce.Exception != null)
            {
                throw responce.Exception;
            }
            if (responce.Value == null)
            {
                throw new InvalidOperationException("Server return empty response on SubscribeTelemtry event");
            }
            var subscribeEventResponse = responce.Value;

            SubscriptionToken st = new SubscriptionToken(subscribeEventResponse.SubscriptionId, getTelemetryNotificationHandler(
                                                             (telemetry) =>
            {
                onTelemetryBatchReceived(telemetry);
            }), _eventSubscriptionWrapper);

            _connectionService.NotificationListener.AddSubscription(st);
        }
        public bool HasVideoPlayerPermission()
        {
            GetLicenseRequest request = new GetLicenseRequest
            {
                ClientId = _connectionService.GetClientId()
            };

            GetLicenseResponse response = _connectionService.Execute <GetLicenseResponse>(request);

            return(response.LicensePermissions.UgcsVideoPlayer);
        }
        public void SubscribeVehicle(System.Action <ClientVehicleDto, Enums.ModificationType> callBack)
        {
            var subscription = new ObjectModificationSubscription
            {
                ObjectType = "Vehicle"
            };

            _eventSubscriptionWrapper.ObjectModificationSubscription = subscription;

            SubscribeEventRequest requestEvent = new SubscribeEventRequest
            {
                ClientId = _connectionService.GetClientId(),

                Subscription = _eventSubscriptionWrapper
            };

            var responce = _connectionService.Submit <SubscribeEventResponse>(requestEvent);

            if (responce.Exception != null)
            {
                logger.Error(responce.Exception);
                throw new InvalidOperationException("Failed to subscribe on vehicle modifications. Try again or see log for more details.");
            }
            var subscribeEventResponse = responce.Value;

            SubscriptionToken st = new SubscriptionToken(subscribeEventResponse.SubscriptionId, getObjectNotificationHandler <Vehicle>(
                                                             (token, vehicleId, vehicle) =>
            {
                if (token == Sdk.Protocol.Encoding.ModificationType.MT_UPDATE || token == Sdk.Protocol.Encoding.ModificationType.MT_CREATE)
                {
                    var newCvd = new ClientVehicleDto()
                    {
                        VehicleId = vehicle.Id,
                        Name      = vehicle.Name
                    };
                    messageReceived(callBack, newCvd, Enums.ModificationType.UPDATED);
                }
                else
                {
                    var newCvd = new ClientVehicleDto()
                    {
                        VehicleId = vehicleId,
                        Name      = string.Empty
                    };
                    messageReceived(callBack, newCvd, Enums.ModificationType.DELETED);
                }
            }), _eventSubscriptionWrapper);

            _connectionService.NotificationListener.AddSubscription(st);
            tokens.Add(st);
        }