aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/ServerManager.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-06-11 07:41:07 -0400
committerMichael <[email protected]>2017-06-11 07:41:07 -0400
commit0d75f701778a0900a58343c4c80c124279bc231f (patch)
tree9715201319348184e2c10f5da9b3d6becb4c2bb7 /ShiftOS_TheReturn/ServerManager.cs
parentc3deaa23fffb7011efb2b5b0f7fc3e754d21f600 (diff)
downloadshiftos_thereturn-0d75f701778a0900a58343c4c80c124279bc231f.tar.gz
shiftos_thereturn-0d75f701778a0900a58343c4c80c124279bc231f.tar.bz2
shiftos_thereturn-0d75f701778a0900a58343c4c80c124279bc231f.zip
skip server connection if server is offline
Diffstat (limited to 'ShiftOS_TheReturn/ServerManager.cs')
-rw-r--r--ShiftOS_TheReturn/ServerManager.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs
index be4f086..00f9653 100644
--- a/ShiftOS_TheReturn/ServerManager.cs
+++ b/ShiftOS_TheReturn/ServerManager.cs
@@ -38,6 +38,7 @@ using System.Net.Sockets;
using System.Diagnostics;
using System.IO;
using System.Reflection;
+using System.Net.NetworkInformation;
namespace ShiftOS.Engine
{
@@ -46,6 +47,29 @@ namespace ShiftOS.Engine
/// </summary>
public static class ServerManager
{
+
+ public static bool ServerOnline
+ {
+ get
+ {
+ try
+ {
+ Ping myPing = new Ping();
+ String host = UserConfig.Get().DigitalSocietyAddress;
+ byte[] buffer = new byte[32];
+ int timeout = 1000;
+ PingOptions pingOptions = new PingOptions();
+ PingReply reply = myPing.Send(host, timeout, buffer, pingOptions);
+ return (reply.Status == IPStatus.Success);
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+ }
+
+
/// <summary>
/// Print connection diagnostic information.
/// </summary>