예제 #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 TestHubConnectionMessage(string connectionId, string input, string expectedId, Type exceptionType = null)
        {
            var hubs = new List <string> {
                "hub", "hub1", "hub.hub1", "h", "hub.hub1.h.hub2", "hub.hub1.h"
            };
            var parser    = new SignalRMessageParser(hubs, _resolver);
            var groupName = GenerateRandomName();

            var message = SignalRMessageUtility.CreateMessage(PrefixHelper.GetHubConnectionId(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 ConnectionDataMessage;

            Assert.NotNull(msg);
            Assert.Equal(expectedId, msg.ConnectionId);
            Assert.Equal(input, msg.Payload.First.GetSingleFramePayload());
        }
예제 #3
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());
 }