diff options
| author | AShifter <[email protected]> | 2017-05-01 13:37:48 -0600 |
|---|---|---|
| committer | AShifter <[email protected]> | 2017-05-01 13:37:48 -0600 |
| commit | d30eb35c9755cf430efa124a9a2576ab6b74c8da (patch) | |
| tree | bbf4c161697b390a96af01a36277c8dc4e52e1a0 /ShiftOS.Server/Program.cs | |
| parent | b842c73b04fb92d9ecaf3d8fcc2df6157c2e8652 (diff) | |
| parent | 7532df70757ecbcaf735a5fc50eee282f555741a (diff) | |
| download | shiftos_thereturn-d30eb35c9755cf430efa124a9a2576ab6b74c8da.tar.gz shiftos_thereturn-d30eb35c9755cf430efa124a9a2576ab6b74c8da.tar.bz2 shiftos_thereturn-d30eb35c9755cf430efa124a9a2576ab6b74c8da.zip | |
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.Server/Program.cs')
| -rw-r--r-- | ShiftOS.Server/Program.cs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index afc2541..97c8a66 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -86,7 +86,18 @@ namespace ShiftOS.Server /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { - + System.Timers.Timer tmr = new System.Timers.Timer(5000); + tmr.Elapsed += (o, a) => + { + if (server.IsOnline) + { + server.DispatchAll(new NetObject("heartbeat", new ServerMessage + { + Name = "heartbeat", + GUID = "server" + })); + } + }; if (!Directory.Exists("saves")) { Directory.CreateDirectory("saves"); @@ -106,11 +117,13 @@ namespace ShiftOS.Server { Console.WriteLine($"Server started on address {server.Address}, port {server.Port}."); ServerStarted?.Invoke(server.Address.ToString()); - }; + tmr.Start(); + }; server.OnStopped += (o, a) => { Console.WriteLine("WARNING! Server stopped."); + tmr.Stop(); }; server.OnError += (o, a) => @@ -283,8 +296,6 @@ namespace ShiftOS.Server /// <param name="msg">Message.</param> public static void Interpret(ServerMessage msg) { - Dictionary<string, object> args = null; - try { Console.WriteLine($@"[{DateTime.Now}] Message received from {msg.GUID}: {msg.Name}"); @@ -312,8 +323,7 @@ namespace ShiftOS.Server try { object contents = null; - bool throwOnNull = false; - + if (mAttrib.ExpectedType == typeof(int)) { @@ -341,7 +351,6 @@ namespace ShiftOS.Server } else if (mAttrib.ExpectedType == typeof(bool)) { - throwOnNull = true; if (msg.Contents.ToLower() == "true") { contents = true; @@ -358,7 +367,6 @@ namespace ShiftOS.Server } else if (mAttrib.ExpectedType == null) { - throwOnNull = false; } else if(mAttrib.ExpectedType == typeof(string)) { |
