blob: 43721de21a2b422fd277b69231e9a513d8ba96c0 (
plain)
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using Tango.TCC.Service.DTO;
namespace Tango.TCC.Service.Hubs
{
public class ResultsHub : Hub
{
private static IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<ResultsHub>();
private static Dictionary<String, String> _connectionsDevices;
public ResultsHub()
{
_connectionsDevices = new Dictionary<string, string>();
}
public void Hello()
{
}
public void setDevice(String deviceId)
{
if(String.IsNullOrEmpty(deviceId))
{
_connectionsDevices.Remove(Context.ConnectionId);
}
else
{
_connectionsDevices[Context.ConnectionId] = deviceId;
}
}
public static void PushResult(ResultDTO result)
{
foreach (var item in _connectionsDevices.ToList().Where(x => x.Value == result.Email))
{
hubContext.Clients.Client(item.Key).setRealTimeResult(result);
}
}
}
}
|