diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-03-05 15:04:14 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-03-05 15:04:14 +0300 |
commit | 2262a47fefddcb0a8abccb50375bdfa159994776 (patch) | |
tree | 729d148d3791d1f49225e763336314684b9af1ff | |
parent | 15c040a4305ed566a7e49ffd67ccaaa8b10a6330 (diff) |
Connect() method
-rw-r--r-- | ClovershellConnection.cs | 11 | ||||
-rw-r--r-- | Program.cs | 9 |
2 files changed, 12 insertions, 8 deletions
diff --git a/ClovershellConnection.cs b/ClovershellConnection.cs index 9d54305..70d6554 100644 --- a/ClovershellConnection.cs +++ b/ClovershellConnection.cs @@ -315,6 +315,17 @@ namespace com.clusterrr.cloverhack }
}
+ public void Connect()
+ {
+ if (Enabled) return;
+ Enabled = true;
+ while (Enabled && !online)
+ {
+ Thread.Sleep(50);
+ }
+ if (!online) throw new Exception("no clovershell connection, make sure your NES Mini connected, turned on and clovershell mod installed");
+ }
+
void epReader_DataReceived(object sender, EndpointDataEventArgs e)
{
var cmd = (ClovershellCommand)e.Buffer[0];
@@ -32,14 +32,7 @@ namespace UsbTest Environment.Exit(-1);
}
var command = args[0].ToLower();
- nes.Enabled = true;
- int t = 300;
- while (!nes.Online)
- {
- Thread.Sleep(10);
- t--;
- if (t == 0) throw new Exception("no clovershell connection, make sure your NES Mini connected, turned on and clovershell mod installed");
- }
+ nes.Connect();
var ping = nes.Ping();
if (ping < 0) throw new Exception("connected to NES Mini but clovershell is not responding");
switch (command)
|