/// <summary> /// Implements the keep alive session. /// </summary> /// <param name="sessionId">The session identifier.</param> /// <param name="seconds">The seconds.</param> /// <exception cref="FaultException">Invalid session provided</exception> public void keepAliveSession(int sessionId, int seconds) { if (!IsSessionValid(sessionId)) { throw FaultExceptionFactory.CreateInvalidSessionIdentifierFault(); } }
/// <summary> /// Implements the enumSessions of T2G-Identification service. /// </summary> /// <param name="request">The request input.</param> /// <returns>The list of know sessions</returns> public enumSessionsOutput enumSessions(enumSessionsInput request) { if (!IsSessionValid(request.Body.sessionId)) { throw FaultExceptionFactory.CreateInvalidSessionIdentifierFault(); } throw FaultExceptionFactory.CreateNotImplementedFault(); }
/// <summary> /// Implements the unsubscribeToServiceNotifications method of T2G Vehicle-Info service. /// </summary> /// <param name="sessionId">The session identifier.</param> /// <param name="subscriptionId">The subscription identifier to unsubscribe.</param> public void unsubscribeToServiceNotifications(int sessionId, int subscriptionId) { if (!_identificationService.IsSessionValid(sessionId)) { throw FaultExceptionFactory.CreateInvalidSessionIdentifierFault(); } lock (_serviceSubscriptionLock) { if (subscriptionId > 0 && subscriptionId <= SupportedServices.Length) { _serviceSubscriptions[subscriptionId - 1] = false; } } }
/// <summary> /// Implements the enableSystemNotification of T2G-Identification services. /// </summary> /// <param name="sessionId">The session identifier.</param> /// <param name="enable">The new enable state for system notifications.</param> /// <exception cref="FaultException">Invalid session provided</exception> public void enableSystemNotifications(int sessionId, bool enable) { lock (_sessionLock) { SessionData sessionInfo; if (!_sessions.TryGetValue(sessionId, out sessionInfo)) { throw FaultExceptionFactory.CreateInvalidSessionIdentifierFault(); } else if (string.IsNullOrEmpty(sessionInfo.NotificationUrl)) { throw FaultExceptionFactory.CreateNoNotificationUrlFault(); } else { _sessions[sessionId].NotificationEnabled = enable; } } }
/// <summary> /// Implements the enumSessions of T2G-Identification service. /// </summary> /// <param name="request">The request input.</param> /// <returns>The list of know systems.</returns> public enumSystemsOutput enumSystems(enumSystemsInput request) { if (!IsSessionValid(request.Body.sessionId)) { throw FaultExceptionFactory.CreateInvalidSessionIdentifierFault(); } systemList systemList = new systemList(); lock (_systemInfoLock) { systemList.Capacity = _systems.Count; systemList.AddRange(_systems.Values); } enumSystemsOutput result = new enumSystemsOutput(); result.Body = new enumSystemsOutputBody(systemList); return(result); }
public getNotificationPeriodsOutput getNotificationPeriods(getNotificationPeriodsInput request) { throw FaultExceptionFactory.CreateNotImplementedFault(); }
public setNotificationPeriodOutput setNotificationPeriod(setNotificationPeriodInput request) { throw FaultExceptionFactory.CreateNotImplementedFault(); }
public enumInhibitedMessagesOutput enumInhibitedMessages(enumInhibitedMessagesInput request) { throw FaultExceptionFactory.CreateNotImplementedFault(); }
public inhibitMessagesOutput inhibitMessages(inhibitMessagesInput request) { throw FaultExceptionFactory.CreateNotImplementedFault(); }
public getServiceInfoOutput getServiceInfo(getServiceInfoInput request) { throw FaultExceptionFactory.CreateNotImplementedFault(); }
public getActiveServicesOutput getActiveServices(getActiveServicesInput request) { throw FaultExceptionFactory.CreateNotImplementedFault(); }
public subscribeToServiceNotificationsOutput subscribeToServiceNotifications(subscribeToServiceNotificationsInput request) { if (!_identificationService.IsSessionValid(request.Body.sessionId)) { throw FaultExceptionFactory.CreateInvalidSessionIdentifierFault(); } string notificationUrl = _identificationService.GetNotificationUrl(request.Body.sessionId); if (string.IsNullOrEmpty(notificationUrl)) { throw FaultExceptionFactory.CreateNoNotificationUrlFault(); } if (request.Body.systemIdList.Count != 0) { throw FaultExceptionFactory.CreateOnlySubscriptionToAllSystemIsSupportedFault(); } int serviceIndex = Array.IndexOf(SupportedServices, (ushort)request.Body.serviceId); if (serviceIndex < 0) { throw FaultExceptionFactory.CreateInvalidServiceIdentifierFault(); } lock (_serviceSubscriptionLock) { _serviceSubscriptions[serviceIndex] = true; _serviceNotificationUrl = notificationUrl; } Dictionary <string, ServiceInfoData> serviceData; lock (_serviceDataLock) { serviceData = new Dictionary <string, ServiceInfoData>(_serviceData[serviceIndex]); } // Notify the subscribers if (serviceData.Count > 0) { DataPackageTests.T2GServiceInterface.Notification.serviceList serviceList = new DataPackageTests.T2GServiceInterface.Notification.serviceList(); serviceList.Capacity = 1; EndpointAddress address = new EndpointAddress(notificationUrl); using (NotificationClient client = new NotificationClient("NotificationClient", address)) { try { client.Open(); foreach (KeyValuePair <string, ServiceInfoData> notification in serviceData) { if (serviceList.Count == 0) { serviceList.Add(notification.Value); } else { serviceList[0] = notification.Value; } client.onServiceNotification(notification.Key, _identificationService.IsSystemOnline(notification.Key), serviceIndex + 1, serviceList); } } finally { if (client.State == CommunicationState.Faulted) { client.Abort(); } } } } subscribeToServiceNotificationsOutputBody body = new subscribeToServiceNotificationsOutputBody(serviceIndex + 1); subscribeToServiceNotificationsOutput result = new subscribeToServiceNotificationsOutput(body); return(result); }
public demandMessageNotificationOutput demandMessageNotification(demandMessageNotificationInput request) { throw FaultExceptionFactory.CreateNotImplementedFault(); }
public subscribeToMessageNotificationsOutput subscribeToMessageNotifications(subscribeToMessageNotificationsInput request) { if (!_identificationService.IsSessionValid(request.Body.sessionId)) { throw FaultExceptionFactory.CreateInvalidSessionIdentifierFault(); } string notificationUrl = _identificationService.GetNotificationUrl(request.Body.sessionId); if (string.IsNullOrEmpty(notificationUrl)) { throw FaultExceptionFactory.CreateNoNotificationUrlFault(); } if (request.Body.systemIdList.Count != 0) { throw FaultExceptionFactory.CreateOnlySubscriptionToAllSystemIsSupportedFault(); } if (request.Body.messageSubscriptionList.Count != 1) { throw FaultExceptionFactory.CreateInvalidSubscriptionCountFault(); } else if (request.Body.messageSubscriptionList[0].notificationMode != notificationModeEnum.onChanges) { throw FaultExceptionFactory.CreateOnlyOnChangeNotificationSupportedFault(); } int messageIndex = Array.IndexOf(SupportedMessages, request.Body.messageSubscriptionList[0].messageId); if (messageIndex < 0) { throw FaultExceptionFactory.CreateInvalidMessageIdentifierFault(); } int subscriptionId; lock (_messageSubscriptionLock) { _messageSubscriptions[messageIndex] = true; _messageNotificationUrl = notificationUrl; subscriptionId = messageIndex + 1; } Dictionary <string, MessageBase> messageData; lock (_messageDataLock) { messageData = new Dictionary <string, MessageBase>(_messagesData[messageIndex]); } // Notify the subscribers if (messageData.Count > 0) { EndpointAddress address = new EndpointAddress(notificationUrl); using (NotificationClient client = new NotificationClient("NotificationClient", address)) { try { client.Open(); foreach (MessageBase notification in messageData.Values) { client.onMessageNotification(notification.systemId, notification.messageId, notification.fieldList, notification.timestamp, notification.inhibited); } } finally { if (client.State == CommunicationState.Faulted) { client.Abort(); } } } } subscribeToMessageNotificationsOutput result = new subscribeToMessageNotificationsOutput(); result.Body = new DataPackageTests.T2GServiceInterface.VehicleInfo.subscribeToMessageNotificationsOutputBody(subscriptionId); return(result); }