예제 #1
0
        protected override IList <string> GetSignals(string userId, string connectionId)
        {
            var signals = _hubs.SelectMany(info =>
            {
                var items = new List <string>
                {
                    PrefixHelper.GetHubName(info.Name),
                    PrefixHelper.GetHubConnectionId(info.CreateQualifiedName(connectionId)),
                };

                if (!String.IsNullOrEmpty(userId))
                {
                    items.Add(PrefixHelper.GetHubUserId(info.CreateQualifiedName(userId)));
                }

                return(items);
            })
                          .Concat(new[]
            {
                PrefixHelper.GetConnectionId(connectionId),
                PrefixHelper.GetAck(connectionId)
            });

            return(signals.ToList());
        }
        public void TestHubMessage(string connectionId, string input, Type exceptionType = null)
        {
            var hubs = new List <string> {
                "h-", "a", "a.connection1"
            };
            var parser    = new SignalRMessageParser(hubs, _resolver);
            var groupName = GenerateRandomName();

            var message = SignalRMessageUtility.CreateMessage(PrefixHelper.GetHubName(connectionId), input);
            var excludedConnectionIds = new string[] { GenerateRandomName(), GenerateRandomName() };

            message.Filter = GetFilter(excludedConnectionIds.Select(s => PrefixHelper.GetConnectionId(s)).ToList());

            if (exceptionType != null)
            {
                Assert.Throws(exceptionType, () => parser.GetMessages(message).ToList());
                return;
            }

            var msgs = parser.GetMessages(message).ToList();

            Assert.Single(msgs);
            var msg = msgs[0].Message as BroadcastDataMessage;

            Assert.NotNull(msg);
            Assert.Equal <string>(excludedConnectionIds, msg.ExcludedList);
            Assert.Equal(input, msg.Payloads["json"].GetSingleFramePayload());
        }
 public ClientProxy(IConnection connection, IHubPipelineInvoker invoker, string hubName, IList <string> exclude)
 {
     _connection = connection;
     _invoker    = invoker;
     _hubName    = hubName;
     _exclude    = exclude;
     _signal     = PrefixHelper.GetHubName(_hubName);
 }
예제 #4
0
        public Task Invoke(string method, params object[] args)
        {
            var invocation = new ClientHubInvocation
            {
                Hub    = _hubName,
                Method = method,
                Args   = args
            };

            return(_send(PrefixHelper.GetHubName(_hubName), invocation, _exclude));
        }
예제 #5
0
 protected override IList <string> GetSignals(string connectionId)
 {
     return(_hubs.SelectMany(info => new[] { PrefixHelper.GetHubName(info.Name), PrefixHelper.GetHubConnectionId(info.CreateQualifiedName(connectionId)) })
            .Concat(new[] { PrefixHelper.GetConnectionId(connectionId), PrefixHelper.GetAck(connectionId) })
            .ToList());
 }