-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRealFeelAPI.cs
More file actions
56 lines (48 loc) · 1.79 KB
/
RealFeelAPI.cs
File metadata and controls
56 lines (48 loc) · 1.79 KB
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
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
namespace RealFeel
{
internal class API
{
private HttpClient client = new HttpClient();
internal bool Busy;
internal void Send(int Strength, int SensorID = 0, bool IsPulse = false, int PatternInterval = 200)
{
if (Busy)
{
Console.WriteLine("Busy..");
return;
}
//Task.Run(() =>
{
Busy = true;
Console.WriteLine($"Sending Strength: {Strength}");
try
{
_ = client.PostAsync("http://127.0.0.1:9020/vibrate", new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("Strength", Strength.ToString()),
new KeyValuePair<string, string>("SensorID", SensorID.ToString()),
new KeyValuePair<string, string>("IsPulse", (Strength != 0 && IsPulse).ToString()), // No strength should be constant
new KeyValuePair<string, string>("PatternInterval", PatternInterval.ToString()),
}), new CancellationTokenSource(900).Token).Result;
}
catch (Exception e)
{
Console.WriteLine(e);
}
Console.WriteLine($"Sent Strength: {Strength}");
Busy = false;
}//);
}
public class RealFeelRequest
{
public int Strength;
public int SensorID; // Default Is 4 Max. User Can Adjust To More.
public bool IsPulse;
public int PatternInterval = 200; // This is for IsPulse! - Must be 100 or more!
}
}
}