Пример #1
0
        protected ProcessResult SendGroupResponse <TResponse>(TResponse response, string message         = null,
                                                              Action <string, Exception> handleException = null) where TResponse : IResultBase
        {
            var shareGroups = response.ShareGroups();

            var responseToOriginator      = MappingService.Map <TResponse>(response);
            var groupResponseToOriginator = new SignalRGroupResponse(responseToOriginator, message);
            var result = this.ExecuteGroupAction(response.OriginatorGroup,
                                                 group => group.groupResponseReceived(groupResponseToOriginator),
                                                 exception => handleException?.Invoke(response.OriginatorGroup, exception));

            if (shareGroups == null || !shareGroups.Any())
            {
                return(result);
            }

            var responseToShareGroups      = MappingService.Map <TResponse>(response);
            var groupResponseToShareGroups = new SignalRGroupResponse(responseToShareGroups);

            foreach (var shareGroup in shareGroups)
            {
                responseToShareGroups.WithOriginatorGroup(shareGroup);
                this.ExecuteGroupAction(shareGroup,
                                        group => group.groupResponseReceived(groupResponseToShareGroups),
                                        exception => handleException?.Invoke(shareGroup, exception));
            }

            return(result);
        }
Пример #2
0
        public static THub ExecuteOnAllClients <THub, TResponse>(this THub hub, TResponse response,
                                                                 Action <dynamic, SignalRGroupResponse> actionsOnAllClients)
            where THub : Hub
            where TResponse : IResponse
        {
            var groupResponse = new SignalRGroupResponse(response);

            actionsOnAllClients?.Invoke(hub.Clients.All, groupResponse);
            return(hub);
        }