Skip to content

Commit e68c92c

Browse files
committed
faster search for ctrl-d
1 parent eafec2b commit e68c92c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/echo/freedom-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var requestedEndpoint: net.Endpoint = {
1515

1616
// Character code for CTRL-D.
1717
// When received, we close the connection.
18-
var CTRL_D_CODE_HEX = '04';
18+
const CTRL_D_CODE = 4;
1919

2020
var loggingController = freedom['loggingcontroller']();
2121
loggingController.setDefaultFilter(loggingTypes.Destination.console,
@@ -42,7 +42,7 @@ server.listen().then((actualEndpoint) => {
4242

4343
connection.dataFromSocketQueue.setSyncHandler((data:ArrayBuffer): void => {
4444
log.info('%1: received %2 bytes', id, data.byteLength);
45-
if (new Buffer(data).toString('hex') === CTRL_D_CODE_HEX) {
45+
if (data.byteLength === 1 && new Uint8Array(data)[0] === CTRL_D_CODE) {
4646
connection.close();
4747
} else {
4848
connection.send(data);

0 commit comments

Comments
 (0)