-
Notifications
You must be signed in to change notification settings - Fork 0
/
bClient.cs
48 lines (40 loc) · 1.55 KB
/
bClient.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
using System;
using System.Threading;
using System.Threading.Tasks;
using Buttplug.Client;
using Buttplug.Client.Connectors.WebsocketConnector;
using Buttplug.Core.Messages;
using Terraria;
using Color = Microsoft.Xna.Framework.Color;
using static Viberaria.tPlayer;
using static Viberaria.bVibration;
using static Viberaria.tSystem;
namespace Viberaria;
public static class bClient
{
public static readonly ButtplugClient _client = new("Viberaria");
private static readonly ButtplugWebsocketConnector _connector = new(new Uri("ws://localhost:12345"));
public static void ClientHandles()
{
_client.DeviceAdded += HandleDeviceAdded;
_client.DeviceRemoved += HandleDeviceRemoved;
}
public static async void ClientConnect()
{
if (_client.Connected == true)
return;
await _client.ConnectAsync(_connector);
await Task.Delay(1000);
await _client.StartScanningAsync();
}
public static async void ClientDisconnect()
=> await _client.DisconnectAsync();
public static async void ClientStartScanning()
=> await _client.StartScanningAsync();
public static async void ClientStopScanning()
=> await _client.StopScanningAsync();
private static void HandleDeviceAdded(object obj, DeviceAddedEventArgs args)
=> tChat.LogToPlayer($"{args.Device.Name} has been added!", Color.Fuchsia);
private static void HandleDeviceRemoved(object obj, DeviceRemovedEventArgs args)
=> tChat.LogToPlayer($"{args.Device.Name} has been removed!", Color.Aqua);
}