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.
- Listed in Global namespace: S
- Inherits or implements
IRemoteConsole - Documented in Remote console
Constructors
| Member | What it is |
|---|---|
ServerRemoteConsole() | Creates a ServerRemoteConsole with default values. |
Fields
| Member | What it is |
|---|---|
const int ServerConsolePort | TCP port the console listens on (1758). |
const int ServerLoggingPort | Logging port constant (1759); not used in this class. |
5 private and internal fields
| Member | What it is |
|---|---|
private List<ClientHandler> allClientHandlers | Clients currently connected. |
private ManualResetEvent allDone | Signal that lets the listen loop accept the next connection. |
private Thread connectionHandlingThread | The background listening thread. |
private static Logger logger | NLog logger for this class. |
private Socket socket | The listening socket. |
Properties
| Member | What it is |
|---|---|
static bool IsActive { get; private set; } | True while the remote console is started and listening. |
Events
| Member | What it is |
|---|---|
event Action<UserInfoWithPermissions, IRemoteConsoleHandler> ConsoleConnected | Fired when a client passes the token check. |
event Action<UserInfoWithPermissions, IRemoteConsoleHandler> ConsoleDisconnected | Fired when a client disconnects. |
Methods
| Member | What 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
| Member | What 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. |