Beispiel #1
0
 public async Task DelayRemoveTargetAsync(HubConnectionContext connection, RouteTarget target)
 {
     if (_options.EnableStickySession && connection.TryGetUid(out var uid))
     {
         await _cache.SetStringAsync(uid, target.ToString(), ExpireIn30Min);
     }
 }
Beispiel #2
0
        public bool TryGetTarget(HubConnectionContext connection, out RouteTarget target)
        {
            var targetValue = _options.EnableStickySession && connection.TryGetUid(out var uid)
                ? _cache.GetString(uid)
                : null;

            target = RouteTarget.FromString(targetValue);
            return(target != null);
        }
Beispiel #3
0
 public static bool TryGetRouteTarget(this HubConnectionContext connection, out RouteTarget target)
 {
     target = null;
     if (connection.Metadata.TryGetValue("Target", out var value))
     {
         target = (RouteTarget)value;
     }
     return(target != null);
 }
Beispiel #4
0
        private void UpdateConnectionCount(string hubName, RouteTarget target, Func <int, int> updateFactory)
        {
            if (_serverStatus.TryGetValue(hubName, out var serverStatus))
            {
                serverStatus.TryUpdate(target.ServerId, updateFactory);
            }

            if (_connectionStatus.TryGetValue($"{hubName}:{target.ServerId}", out var connectionStatus))
            {
                connectionStatus.TryUpdate(target.ConnectionId, updateFactory);
            }
        }
Beispiel #5
0
 public static void AddRouteTarget(this HubConnectionContext connection, RouteTarget target)
 {
     connection.Metadata.Add("Target", target);
 }