1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 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<string, ServiceHubContext> ServiceHubContexts { get; } = new();
- /// <summary>
- /// µo°e«H®§¦Ü¹ï¦C©Î¥DÃD
- /// </summary>
- /// <param name="name">QueueName or TopicName</param>
- /// <param name="message">°T®§</param>
- /// <returns></returns>
- 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;
- }
- }
- }
- }
|