using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Linq; using StackExchange.Redis; using System.Collections.Concurrent; using Microsoft.Azure.SignalR.Management; namespace TEAMModelOS.SDK.DI { public static class AzureSignalRExtensions { private static ConcurrentDictionary ServiceHubContexts { get; } = new(); /// /// 發送信息至對列或主題 /// /// QueueName or TopicName /// 訊息 /// public static ServiceHubContext GetHubContext(this ServiceManager sm, string name) { try { ServiceHubContext hub = ServiceHubContexts.GetOrAdd(name, (x) => sm.CreateHubContextAsync(name, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()); return hub; } catch { throw; } } } }