-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathWebsocketServer.cs
91 lines (79 loc) · 2.12 KB
/
WebsocketServer.cs
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebSocketSharp;
using WebSocketSharp.Server;
using Serilog;
namespace opentuner
{
public class WSClientConnection : WebSocketBehavior
{
protected override void OnMessage(MessageEventArgs e)
{
//Send(e.Data);
}
protected override void OnClose(CloseEventArgs e)
{
//base.OnClose(e);
Serilog.Log.Information("Ws closed: " + e.ToString());
}
protected override void OnOpen()
{
//base.OnOpen();
Serilog.Log.Information("Ws open: " + this.ID);
}
}
public class OTWebsocketServer
{
WebSocketServer ws_server;
public OTWebsocketServer(int port)
{
ws_server = new WebSocketServer(port);
ws_server.AddWebSocketService<WSClientConnection>("/");
ws_server.Start();
}
public void Broadcast(string msg)
{
if (ws_server != null)
{
ws_server.WebSocketServices.Broadcast(msg);
}
}
}
[Serializable]
public class monitorMessage_packet
{
public monitorMessage_packet_rx rx;
public monitorMessage_packet_ts ts;
}
[Serializable]
public class monitorMessage_packet_rx
{
public int rfport;
public int demod_state;
public int ber;
public int frequency;
public int symbolrate;
public int mer;
public int modcod;
public string ts_ip_addr;
public int ts_ip_port;
}
[Serializable]
public class monitorMessage_packet_ts
{
public string service_name;
public string service_provider_name;
public int null_ratio;
public int[][] PIDs;
}
[Serializable]
public class monitorMessage
{
public string type;
public double timestamp;
public monitorMessage_packet packet;
}
}