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

TelnetSocket.setEncoding() causes 'data' listener to fail. #11

Open
jordan-tiona opened this issue Nov 1, 2022 · 0 comments
Open

TelnetSocket.setEncoding() causes 'data' listener to fail. #11

jordan-tiona opened this issue Nov 1, 2022 · 0 comments

Comments

@jordan-tiona
Copy link

const server = new Telnet.TelnetServer( rawSocket => {
    const telnetSocket = new Telnet.TelnetSocket();
    telnetSocket.attach( rawSocket );
    telnetSocket.setEncoding( "utf8" );
} ).netServer;

The first time any data is received after this point there is a TypeError given:

C:\Projects\mud\node_modules\ranvier-telnet\index.js:154
      databuf.copy(inputbuf, inputlen);
              ^

TypeError: databuf.copy is not a function
    at Socket.<anonymous> (C:\Projects\mud\node_modules\ranvier-telnet\index.js:154:15)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

It appears that the incoming data is not being checked for encoding:

connection.on('data', (databuf) => {
    databuf.copy(inputbuf, inputlen);
    inputlen += databuf.length;

My attempted fixes have proven ineffective. I will update if a solution is found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant