We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eafec2b commit e68c92cCopy full SHA for e68c92c
1 file changed
src/echo/freedom-module.ts
@@ -15,7 +15,7 @@ var requestedEndpoint: net.Endpoint = {
15
16
// Character code for CTRL-D.
17
// When received, we close the connection.
18
-var CTRL_D_CODE_HEX = '04';
+const CTRL_D_CODE = 4;
19
20
var loggingController = freedom['loggingcontroller']();
21
loggingController.setDefaultFilter(loggingTypes.Destination.console,
@@ -42,7 +42,7 @@ server.listen().then((actualEndpoint) => {
42
43
connection.dataFromSocketQueue.setSyncHandler((data:ArrayBuffer): void => {
44
log.info('%1: received %2 bytes', id, data.byteLength);
45
- if (new Buffer(data).toString('hex') === CTRL_D_CODE_HEX) {
+ if (data.byteLength === 1 && new Uint8Array(data)[0] === CTRL_D_CODE) {
46
connection.close();
47
} else {
48
connection.send(data);
0 commit comments