-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheartbeat.cs
More file actions
26 lines (22 loc) · 853 Bytes
/
heartbeat.cs
File metadata and controls
26 lines (22 loc) · 853 Bytes
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
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DiscordWSS {
public class heartbeat {
public static void Heartbeat(ClientWebSocket socket, int hb) {
Thread.CurrentThread.IsBackground = false;
var heartbeatJSONs = @"{'op': 1,'d': 'null'}";
var details = JObject.Parse(heartbeatJSONs);
while(socket.State == WebSocketState.Open) {
socket.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(details.ToString())), WebSocketMessageType.Text, true, CancellationToken.None).Wait();
Thread.Sleep(hb);
}
Logger.Log(Logger.LogLevel.info, details.ToString());
}
}
}