Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Tutorials
How to Properly shut down your Emulator...
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="dogfishcat" data-source="post: 428187" data-attributes="member: 79616"><p>Interested, although many people should already know this, and not have to be taught.</p><p></p><p>What I've done on my emulator is add hotkeys, when holding down CTRL + C you can close the emulator, but holding CTRL + R reboots the emulator, both take 5 seconds, feel free to use this. I would release this in its own thread, but the code isn't a full release as it's not coded in Plus, but a basic C# developer should be able to convert it.</p><p></p><p>Your while loop in Program, use this...</p><p>[CODE]var rebootAfterClose = false;</p><p></p><p>while (true)</p><p>{</p><p> var input = Console.ReadKey();</p><p></p><p> if (input.Key == ConsoleKey.C && input.Modifiers == ConsoleModifiers.Control)</p><p> {</p><p> break;</p><p> }</p><p></p><p> if (input.Key != ConsoleKey.R || input.Modifiers != ConsoleModifiers.Control)</p><p> {</p><p> continue;</p><p> }</p><p></p><p> rebootAfterClose = true;</p><p></p><p> break;</p><p>}</p><p></p><p>Server?.Stop(rebootAfterClose);</p><p></p><p>[/CODE]</p><p></p><p>You should probably run Stop() method in a separate task too, not too sure but I think they thread.Sleep for 5 seconds? this way the users don't freeze until shutdown or reboot.</p><p>[CODE]public void Stop(bool restart)</p><p>{</p><p> Task.Factory.StartNew(() =></p><p> {</p><p> var shutdownMessage = Program.Server.LanguageHandler.TryGetValue("server.shutdown.message");</p><p> var shutdownPacket = new BroadcastMessageAlertComposer(shutdownMessage);</p><p></p><p> Program.Server.GameHandler.PlayerHandler.SendPacketToPlayers(shutdownPacket);</p><p></p><p> ConsoleUpdater.Stop();</p><p></p><p> Console.Clear();</p><p> Console.WriteLine();</p><p> Console.Title = "Stopping...";</p><p></p><p> Logger.Warn("Server is " + (restart ? "rebooting" : "shutting down") + "....");</p><p></p><p> Thread.Sleep(5000);</p><p></p><p> Dispose();</p><p></p><p> if (restart)</p><p> {</p><p> Process.Start(Assembly.GetExecutingAssembly().Location);</p><p> }</p><p></p><p> Environment.Exit(0);</p><p> }).Wait();</p><p>}[/CODE]</p></blockquote><p></p>
[QUOTE="dogfishcat, post: 428187, member: 79616"] Interested, although many people should already know this, and not have to be taught. What I've done on my emulator is add hotkeys, when holding down CTRL + C you can close the emulator, but holding CTRL + R reboots the emulator, both take 5 seconds, feel free to use this. I would release this in its own thread, but the code isn't a full release as it's not coded in Plus, but a basic C# developer should be able to convert it. Your while loop in Program, use this... [CODE]var rebootAfterClose = false; while (true) { var input = Console.ReadKey(); if (input.Key == ConsoleKey.C && input.Modifiers == ConsoleModifiers.Control) { break; } if (input.Key != ConsoleKey.R || input.Modifiers != ConsoleModifiers.Control) { continue; } rebootAfterClose = true; break; } Server?.Stop(rebootAfterClose); [/CODE] You should probably run Stop() method in a separate task too, not too sure but I think they thread.Sleep for 5 seconds? this way the users don't freeze until shutdown or reboot. [CODE]public void Stop(bool restart) { Task.Factory.StartNew(() => { var shutdownMessage = Program.Server.LanguageHandler.TryGetValue("server.shutdown.message"); var shutdownPacket = new BroadcastMessageAlertComposer(shutdownMessage); Program.Server.GameHandler.PlayerHandler.SendPacketToPlayers(shutdownPacket); ConsoleUpdater.Stop(); Console.Clear(); Console.WriteLine(); Console.Title = "Stopping..."; Logger.Warn("Server is " + (restart ? "rebooting" : "shutting down") + "...."); Thread.Sleep(5000); Dispose(); if (restart) { Process.Start(Assembly.GetExecutingAssembly().Location); } Environment.Exit(0); }).Wait(); }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Tutorials
How to Properly shut down your Emulator...
Top