Table of Contents

Class WakeOnDemandListener

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

Answers Minecraft clients on the server's port while the real server is stopped, so a stopped server can say "I'm asleep, come in and I'll wake up" instead of just refusing the connection.

It speaks the small, stable part of the protocol needed for that: the handshake, the server-list status, and the login disconnect. Pressing Join is what wakes the server — the client re-pings every few seconds while the multiplayer screen is open, so waking on a status request would start the server over and over for people who are not even playing.

With a Playit tunnel this socket is reachable from the internet, so everything it reads is treated as hostile: lengths are bounded before anything is allocated, every connection has a deadline, and the number of them at once is capped.

public sealed class WakeOnDemandListener : IDisposable
Inheritance
WakeOnDemandListener
Implements
Inherited Members

Properties

IsListening

public bool IsListening { get; }

Property Value

bool

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Start(int, Func<WakeStatus>, Func<string?, bool>)

Starts answering on port. Returns false when the port can't be bound — the caller keeps working, it just means no wake-on-demand for now.

public bool Start(int port, Func<WakeStatus> status, Func<string?, bool> onJoinAttempt)

Parameters

port int

The server's own port.

status Func<WakeStatus>

What the server list shows, asked for on every ping.

onJoinAttempt Func<string, bool>

Somebody pressed Join, with the name they logged in as (null if the client sent none). Returns whether the server is being woken for them, which decides what they are told. Called on the connection's thread.

Returns

bool

Stop()

Releases the port. Must be called before the real server starts, or Java finds the port busy — and the app would offer to kill the process holding it, which would be this one.

public void Stop()