8000 update repl example · marcelkottmann/esp32-javascript@062cb27 · GitHub
[go: up one dir, main page]

Skip to content

Commit 062cb27

Browse files
update repl example
1 parent f6793cc commit 062cb27

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

examples/repl.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
/**
2-
*
2+
*
33
* A network based REPL (Read–eval–print loop).
4-
*
4+
*
55
* Usage:
66
* netcat [IP-ADDRESS] 1234
7-
*
7+
*
88
* After successful connection a prompt appears: '>'
99
* Then type [USER]:[PASS] (the defaults are esp32:esp32)
1010
* After successful authentication you will see "====> authorized."
11-
*
12-
* After that you can type every JS expression, which then gets
13-
* evaluated in esp32-javascript and the result is printed.
14-
*
11+
*
12+
* After that you can type every JS expression, which then gets
13+
* evaluated in esp32-javascript and the result is printed.
14+
*
1515
*/
1616
var configManager = require("esp32-javascript/config");
1717

1818
var PROMPT = "> ";
19+
var textDecoder = new TextDecoder();
1920

2021
function writeOutput(socket, result) {
2122
socket.write(result);
@@ -27,7 +28,8 @@ require("socket-events").sockListen(
2728
function (socket) {
2829
var authorized = false;
2930
var _ = undefined;
30-
socket.onData = function (data) {
31+
socket.onData = function (buffer) {
32+
var data = textDecoder.decode(buffer);
3133
var result = null;
3234
if (!authorized) {
3335
var accessConfig = configManager.config.access;

0 commit comments

Comments
 (0)
0