-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApi.cs
52 lines (42 loc) · 1.33 KB
/
Api.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
using MySqlX.XDevAPI.Common;
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Net.NetworkInformation;
namespace ndr
{
internal class Api
{
private string status;
public string get_status(){
try
{
Ping myPing = new Ping();
PingReply reply = myPing.Send("nadiraa.my.id", 1000);
if (reply != null)
{
var url = "http://localhost/rpc/api.php/";
var httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Accept = "application/json";
var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
status = "True";
return result;
}
}
}
catch
{
string result = "Not Connected";
return result;
}
string tidak = "Not Available";
return tidak;
}
}
}