Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented telnet TM option #135

Open
wants to merge 2 commits into
base: feat/telnet-eor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions backend/src/core/sockets/socket-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ export class SocketManager extends Server<

socket.emit('setEchoMode', true);
}

break;
}

case TelnetOptions.TELOPT_TM: {
if (negotiation.server === TelnetControlSequences.DO) {
socket.emit('requestTimingMark', () => {
this.mudConnections[socket.id].telnet?.sendTimingMark();
});
}
}
}
});
Expand Down
1 change: 1 addition & 0 deletions backend/src/core/sockets/types/server-to-client-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export interface ServerToClientEvents {
mudDisconnected: () => void;
mudConnected: () => void;
setEchoMode: (showEchos: boolean) => void;
requestTimingMark: (callback: () => void) => void;
}
2 changes: 1 addition & 1 deletion backend/src/features/telnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The TelnetClient class handles these negotiation commands, regardless of their o
| STATUS | Full | DO | WILL | Allows for comparisson of the status of the server and the client. Allows for comparison of the negotiated options | https://github.com/unitopia-de/webmud3/issues/130 |
| MSSP (Mud Server Status Protocol) | Full | DO | WILL | Allows our client to retrieve basic information about the mud, like the current player count or the server name. | https://github.com/unitopia-de/webmud3/issues/131 |
| EOR (End of Record) | Full | DO | WILL | Allows for the server to signal the end of a record which is very useful to segment messages to the client. | https://github.com/unitopia-de/webmud3/issues/112 |
| TM (TIMING MARK) | Full | DO | WILL | This option is currently used to generate Ping round-trips from the server to the client. | https://github.com/unitopia-de/webmud3/issues/129 |
| NAWS (Negotiate About Window Size) | Partial | WILL (+ Sub) | DO | We support this option to subnegotiate the window size. However, we send static values for the window size (80x25) and it does look like Unitopia is ignoring these values. | https://github.com/unitopia-de/webmud3/issues/108 |
| CHARSET | Partial | DO / WILL (+ Sub) | WILL (+ Sub) / DO | We support this option to subnegotiate the character set with the server. However, we only accept UTF-8. If the server does not subnogitiate for UTF-8, an error will be thrown and the connection will be closed. | https://github.com/unitopia-de/webmud3/issues/111 |
| LINEMODE | Partial | WILL | DO | We support the LINEMODE option. However, the server wants us to send our input buffer whenever ANY ASCII control character is entered (FORWARDMASK), which is unsupported. On the other side, we do support SOFT_TAB and EDIT MODES | https://github.com/unitopia-de/webmud3/issues/114 |
Expand All @@ -43,7 +44,6 @@ The TelnetClient class handles these negotiation commands, regardless of their o
| AUTH | Unsupported | WONT | DO | We dont support any authentication options for now. | |
| MXP (Mud Extention Protocol) | Unsupported | WONT | DO | We dont support the MXP option for now, but we want to support this option in the future. | |
| GMCP (Generic Mud Communication Protocol) | Unsupported | WONT | DO | We dont support the GMCP option for now, but we want to support this option in the future. | |
| TIMING MARK | Unsupported | Not negotiated | Not negotiated | Unsupported. Includes dirty IAC Commands in our clean data handling. | https://github.com/unitopia-de/webmud3/issues/129 |

## How to handle a new option

Expand Down
10 changes: 10 additions & 0 deletions backend/src/features/telnet/telnet-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export class TelnetClient extends EventEmitter<TelnetClientEvents> {
this.telnetSocket.writeSub(TelnetOptions.TELOPT_STATUS, buffer);
}

public sendTimingMark(): void {
this.telnetSocket.writeWill(TelnetOptions.TELOPT_TM);
}

public disconnect(): void {
logger.info(`[Telnet-Client] Disconnect`);

Expand Down Expand Up @@ -243,6 +247,12 @@ export class TelnetClient extends EventEmitter<TelnetClientEvents> {
server: TelnetControlSequences.DO,
});

// Timing Mark is excluded here since it needs a whole round-trip to the client
// We dont want to answer directly so we wait for the client to send the timing mark
if (option === TelnetOptions.TELOPT_TM) {
return;
}

const handler = this.optionsHandler.get(option);

if (
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/app/features/sockets/sockets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export class SocketsService {
this.socket.on('setEchoMode', (showEchos: boolean) => {
this.handleSetEchoMode(showEchos);
});

this.socket.on('requestTimingMark', (callback: () => void) => {
this.handleTimingMark(callback);
});
}

public connectToMud(): void {
Expand Down Expand Up @@ -194,6 +198,12 @@ export class SocketsService {

this.onSetEchoMode.emit(showEchos);
};

private handleTimingMark = (callback: () => void) => {
console.info('[Sockets] Sockets-Service: Got and answer a Timing Mark');

callback();
};
}

// Temporär auskommentierte Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export interface ServerToClientEvents {
mudDisconnected: () => void;
mudConnected: () => void;
setEchoMode: (showEchos: boolean) => void;
requestTimingMark: (callback: () => void) => void;
}