Skip to main content

ServerRemoteConsole

A class in Root.Township, the global namespace.

The TCP remote console: listens on port 1758 on a background thread, checks the JWT a client sends first and then hands the connection to a ClientHandler. Started by ServerConsoleManager.

Constructors​

MemberWhat it is
ServerRemoteConsole()Creates a ServerRemoteConsole with default values.

Fields​

MemberWhat it is
const int ServerConsolePortTCP port the console listens on (1758).
const int ServerLoggingPortLogging port constant (1759); not used in this class.
5 private and internal fields
MemberWhat it is
private List<ClientHandler> allClientHandlersClients currently connected.
private ManualResetEvent allDoneSignal that lets the listen loop accept the next connection.
private Thread connectionHandlingThreadThe background listening thread.
private static Logger loggerNLog logger for this class.
private Socket socketThe listening socket.

Properties​

MemberWhat it is
static bool IsActive { get; private set; }True while the remote console is started and listening.

Events​

MemberWhat it is
event Action<UserInfoWithPermissions, IRemoteConsoleHandler> ConsoleConnectedFired when a client passes the token check.
event Action<UserInfoWithPermissions, IRemoteConsoleHandler> ConsoleDisconnectedFired when a client disconnects.

Methods​

MemberWhat it is
void Close()Terminates every client, closes the listening socket and clears IsActive.
void Start()Sets IsActive and starts the listening thread.
4 private and internal methods
MemberWhat it is
private void CreateClient(Socket clientSocket, JwtSecurityToken clientToken)Wraps an accepted socket in a ClientHandler, tracks it and raises ConsoleConnected.
private void HandleClientTerminated(ClientHandler client)Stops tracking a disconnected client and raises ConsoleDisconnected.
private async void HandleNewConnectionAsync(IAsyncResult ar)Accepts a connection, reads the JWT, validates it with ServerConsoleManager.ValidateConsoleToken and replies "ok" or "Invalid Token".
private void StartSocketListen()Thread body: binds port 1758 on all addresses and accepts connections one at a time, forever.