1
刘磊
2024-12-24 79a7c2707011902ec4df62ed8a285fa2029a1782
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
namespace WIDESEAWCS_SignalR;
 
/// <summary>
/// <inheritdoc cref="INoticeService"/>
/// </summary>
[Injection(Named = "signalr")]
public class SignalrNoticeService : INoticeService
{
    public SignalrNoticeService()
    {
    }
 
    /// <inheritdoc/>
    public async Task UpdatePassWord(string userId, List<string> clientIds, string message)
    {
        //发送消息给用户
        await GetHubContext().Clients.Users(clientIds).NewMessage(message);
    }
 
    /// <inheritdoc/>
    public async Task NewMesage(List<string> userIds, List<string> clientIds, string message)
    {
        //发送消息给用户
        await GetHubContext().Clients.Users(clientIds).NewMessage(message);
    }
 
    /// <inheritdoc/>
    public async Task UserLoginOut(string userId, List<string> clientIds, string message)
    {
        //发送消息给用户
        await GetHubContext().Clients.Users(clientIds).LoginOut(message);
    }
 
    #region MyRegion
 
    /// <summary>
    /// 获取hubContext
    /// </summary>
    /// <returns></returns>
    private IHubContext<SimpleHub, ISimpleHub> GetHubContext()
    {
        //解析服务
        var service = App.GetService<IHubContext<SimpleHub, ISimpleHub>>();
        return service;
    }
 
    /// <inheritdoc/>
    public async Task StackerData(int? userId, List<string> clientIds, object message)
    {
        //发送消息给用户
        await GetHubContext().Clients.Users(clientIds).StackerData(message);
    }
 
    /// <inheritdoc/>
    public async Task LineData(int? userId, List<string> clientIds, object message)
    {
        //发送消息给用户
        await GetHubContext().Clients.Users(clientIds).LineData(message);
    }
 
    /// <inheritdoc/>
    public async Task Logs(List<string> clientIds, object message)
    {
        //发送消息给用户
        await GetHubContext().Clients.Users(clientIds).Logs(message);
    }
 
    #endregion MyRegion
}