Ejemplo n.º 1
0
 private void OnUnsubscribeChannels(object sender, MapRequestEventArgs <v12.Protocol.ChannelSubscribe.UnsubscribeChannels, long> args)
 {
     Store.ExecuteWithLock(() =>
     {
         OnUnsubscribeChannelsCore(sender, args);
     });
 }
Ejemplo n.º 2
0
        private void OnUnsubscribeChannelsCore(object sender, MapRequestEventArgs <v12.Protocol.ChannelSubscribe.UnsubscribeChannels, long> args)
        {
            var handler   = (v12.Protocol.ChannelSubscribe.IChannelSubscribeStore)sender;
            var sessionId = GetSessionId(handler);

            HashSet <long> startedChannels, stoppedChannels, closedChannels, invalidChannels;

            if (!Store.ValidateChannelIds(sessionId, args.Request.Body.ChannelIds.Values, out startedChannels, out stoppedChannels, out closedChannels, out invalidChannels))
            {
                args.FinalError = handler.ErrorInfo().RequestDenied();
                return;
            }
            foreach (var kvp in args.Request.Body.ChannelIds)
            {
                var channelId = kvp.Value;
                if (invalidChannels.Contains(channelId) || closedChannels.Contains(channelId))
                {
                    args.ErrorMap[kvp.Key] = handler.ErrorInfo().InvalidState($"Channel {channelId} is not streaming.");
                    continue;
                }
                if (Store.StopChannelStreaming(sessionId, channelId))
                {
                    args.ResponseMap[kvp.Key] = channelId;
                }
                else
                {
                    args.ErrorMap[kvp.Key] = handler.ErrorInfo().RequestDenied($"Could not stop streaming for Channel {channelId}.");
                }
            }
        }
Ejemplo n.º 3
0
        private void OnGetChannelMetadataCore(object sender, MapRequestEventArgs <v12.Protocol.ChannelSubscribe.GetChannelMetadata, v12.Datatypes.ChannelData.ChannelMetadataRecord> args)
        {
            var handler   = (v12.Protocol.ChannelSubscribe.IChannelSubscribeStore)sender;
            var sessionId = GetSessionId(handler);

            if (!Store.HasChannelSubscription(sessionId))
            {
                var callbacks = CreateChannelStreamingCallbacks(handler);
                if (!Store.StartChannelSubscription(EtpVersion.v12, sessionId, int.MaxValue, TimeSpan.FromSeconds(0), false, callbacks))
                {
                    args.FinalError = handler.ErrorInfo().RequestDenied();
                }
            }

            foreach (var kvp in args.Request.Body.Uris)                                                // Register metadata subscriptions
            {
                var subscriptionInfo = new MockSubscriptionInfo(kvp.Value, handler.Session.SessionId); // Use the actual sesison ID as a namespace.
                if (Store.HasChannelSubscriptionScope(sessionId, subscriptionInfo))
                {
                    continue;
                }

                IList <MockObject> addedChannels;
                if (Store.AddChannelSubscriptionChannelScope(sessionId, subscriptionInfo, out addedChannels) && addedChannels.Count == 1)
                {
                    args.ResponseMap[kvp.Key] = ((MockChannel)addedChannels[0]).ChannelMetadataRecord12(Store.GetChannelId(sessionId, addedChannels[0]));
                }
                else
                {
                    args.ErrorMap[subscriptionInfo.RequestUuid.ToString()] = handler.ErrorInfo().RequestDenied($"URI: {kvp.Value}");
                }
            }
        }
Ejemplo n.º 4
0
 private void OnGetChannelMetadata(object sender, MapRequestEventArgs <v12.Protocol.ChannelSubscribe.GetChannelMetadata, v12.Datatypes.ChannelData.ChannelMetadataRecord> args)
 {
     Store.ExecuteWithLock(() =>
     {
         OnGetChannelMetadataCore(sender, args);
     });
 }
Ejemplo n.º 5
0
 private void OnSubscribeNotifications(object sender, MapRequestEventArgs <v12.Protocol.StoreNotification.SubscribeNotifications, string> args)
 {
     Store.ExecuteWithLock(() =>
     {
         OnSubscribeNotificationsCore(sender, args);
     });
 }
Ejemplo n.º 6
0
        private void OnSubscribeChannelsCore(object sender, MapRequestEventArgs <v12.Protocol.ChannelSubscribe.SubscribeChannels, string> args)
        {
            var handler   = (v12.Protocol.ChannelSubscribe.IChannelSubscribeStore)sender;
            var sessionId = GetSessionId(handler);

            HashSet <long> startedChannels, stoppedChannels, closedChannels, invalidChannels;

            if (!Store.ValidateChannelIds(sessionId, args.Request.Body.Channels.Values.Select(csi => csi.ChannelId), out startedChannels, out stoppedChannels, out closedChannels, out invalidChannels))
            {
                args.FinalError = handler.ErrorInfo().RequestDenied();
                return;
            }
            foreach (var kvp in args.Request.Body.Channels)
            {
                var streamingInfo = kvp.Value;
                var channelId     = streamingInfo.ChannelId;
                if (invalidChannels.Contains(channelId) || closedChannels.Contains(channelId))
                {
                    args.ErrorMap[kvp.Key] = handler.ErrorInfo().InvalidChannelId(channelId);
                    continue;
                }

                var channel = Store.GetChannel(sessionId, channelId);
                if (channel == null || !(channel is IMockGrowingObject))
                {
                    args.ErrorMap[kvp.Key] = handler.ErrorInfo().NotFound($"Missing channel for Channel ID {channelId}");
                    continue;
                }
                var growingObject = channel as IMockGrowingObject;
                if (startedChannels.Contains(channelId))
                {
                    args.ErrorMap[kvp.Key] = handler.ErrorInfo().NotFound($"Channel {channelId} ({growingObject.Mnemonic}) is already streaming.");
                    continue;
                }

                if (Store.StartChannelStreaming(sessionId, channelId, streamingInfo.DataChanges, new MockIndex(streamingInfo)))
                {
                    args.ResponseMap[kvp.Key] = string.Empty;
                }
                else
                {
                    args.ErrorMap[kvp.Key] = handler.ErrorInfo().RequestDenied($"Could not start streaming for Channel {streamingInfo.ChannelId} ({growingObject.Mnemonic}).");
                }
            }
        }
Ejemplo n.º 7
0
        private void OnSubscribeNotificationsCore(object sender, MapRequestEventArgs <v12.Protocol.StoreNotification.SubscribeNotifications, string> args)
        {
            var handler = (v12.Protocol.StoreNotification.IStoreNotificationStore)sender;

            foreach (var kvp in args.Request.Body.Request)
            {
                var callbacks        = CreateStoreNotificationCallbacks(handler);
                var subscriptionInfo = new MockSubscriptionInfo(kvp.Value);
                if (Store.SubscribeObjectNotifications(EtpVersion.v12, false, Store.StoreLastWrite, true, handler.Session.SessionId, subscriptionInfo, callbacks))
                {
                    args.ResponseMap[kvp.Key] = string.Empty;
                }
                else
                {
                    args.ErrorMap[kvp.Key] = handler.ErrorInfo().RequestUuidRejected(kvp.Value);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Handles the GetPartsMetadata message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{GetPartsMetadata, PartsMetadataInfo}"/> instance containing the event data.</param>
 protected virtual void HandleGetPartsMetadata(MapRequestEventArgs <GetPartsMetadata, PartsMetadataInfo> args)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Handles the response to an PutUninitializedDataArrays message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{PutUninitializedDataArrays, string}"/> instance containing the event data.</param>
 protected virtual void HandlePutUninitializedDataArrays(MapRequestEventArgs <PutUninitializedDataArrays, string> args)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Handles the response to an GetDataArrayMetadata message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{GetDataArrayMetadata, DataArrayMetadata}"/> instance containing the event data.</param>
 protected virtual void HandleGetDataArrayMetadata(MapRequestEventArgs <GetDataArrayMetadata, DataArrayMetadata> args)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Handles the PutDataObjects message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{PutDataObjects, PutResponse}"/> instance containing the event data.</param>
 protected virtual void HandlePutDataObjects(MapRequestEventArgs <PutDataObjects, PutResponse> args)
 {
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Handles the response to an PutDataspaces message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{PutDataspaces, string}"/> instance containing the event data.</param>
 protected virtual void HandlePutDataspaces(MapRequestEventArgs <PutDataspaces, string> args)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Handles the PutParts message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{PutParts, string}"/> instance containing the event data.</param>
 protected virtual void HandlePutParts(MapRequestEventArgs <PutParts, string> args)
 {
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Handles the response to an GetChannelMetadata message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{GetChannelMetadata, ChannelMetadataRecord}"/> instance containing the event data.</param>
 protected virtual void HandleGetChannelMetadata(MapRequestEventArgs <GetChannelMetadata, ChannelMetadataRecord> args)
 {
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Handles the response to an GetChangeAnnotations message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{GetChangeAnnotations, ChangeResponseInfo}"/> instance containing the event data.</param>
 protected virtual void HandleGetChangeAnnotations(MapRequestEventArgs <GetChangeAnnotations, ChangeResponseInfo> args)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Handles the GetParts message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{GetParts, ObjectPart}"/> instance containing the event data.</param>
 protected virtual void HandleGetParts(MapRequestEventArgs <GetParts, ObjectPart> args)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Handles the response to an SubscribeChannels message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{SubscribeChannels, string}"/> instance containing the event data.</param>
 protected virtual void HandleSubscribeChannels(MapRequestEventArgs <SubscribeChannels, string> args)
 {
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Handles the DeleteParts message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{DeleteParts, string}"/> instance containing the event data.</param>
 protected virtual void HandleDeleteParts(MapRequestEventArgs <DeleteParts, string> args)
 {
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Handles the response to an OpenChannels message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{OpenChannels, OpenChannelInfo}"/> instance containing the event data.</param>
 protected virtual void HandleOpenChannels(MapRequestEventArgs <OpenChannels, OpenChannelInfo> args)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Handles the response to an DeleteDataspaces message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{DeleteDataspaces, string}"/> instance containing the event data.</param>
 protected virtual void HandleDeleteDataspaces(MapRequestEventArgs <DeleteDataspaces, string> args)
 {
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Handles the response to an TruncateChannels message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{TruncateChannels, DateTime}"/> instance containing the event data.</param>
 protected virtual void HandleTruncateChannels(MapRequestEventArgs <TruncateChannels, DateTime> args)
 {
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Handles the DeleteDataObjects message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{DeleteDataObjects, ArrayOfString}"/> instance containing the event data.</param>
 protected virtual void HandleDeleteDataObjects(MapRequestEventArgs <DeleteDataObjects, ArrayOfString> args)
 {
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Handles the response to an SubscribePartNotifications message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{SubscribePartNotifications, string}"/> instance containing the event data.</param>
 protected virtual void HandleSubscribePartNotifications(MapRequestEventArgs <SubscribePartNotifications, string> args)
 {
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Handles the response to an GetDataSubarrays message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{GetDataSubarrays, Datatypes.DataArrayTypes.DataArray}"/> instance containing the event data.</param>
 protected virtual void HandleGetDataSubarrays(MapRequestEventArgs <GetDataSubarrays, Datatypes.DataArrayTypes.DataArray> args)
 {
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Handles the GetGrowingDataObjectsHeader message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{GetGrowingDataObjectsHeader, DataObject}"/> instance containing the event data.</param>
 protected virtual void HandleGetGrowingDataObjectsHeader(MapRequestEventArgs <GetGrowingDataObjectsHeader, DataObject> args)
 {
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Handles the response to an PutDataSubarrays message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{PutDataSubarrays, string}"/> instance containing the event data.</param>
 protected virtual void HandlePutDataSubarrays(MapRequestEventArgs <PutDataSubarrays, string> args)
 {
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Handles the PutGrowingDataObjectsHeader message from a customer.
 /// </summary>
 /// <param name="args">The <see cref="MapRequestEventArgs{PutGrowingDataObjectsHeader, string}"/> instance containing the event data.</param>
 protected virtual void HandlePutGrowingDataObjectsHeader(MapRequestEventArgs <PutGrowingDataObjectsHeader, string> args)
 {
 }