2

Is there any way to establish a telnet connection in dart?

Basically what I want to achive it's to create a teamspeak 3 bot using Dart.

I tought about using socket with I have no idea about how to go on.

EDIT: I managed to estabilish a socket connection to the ts3 but I cannot make dart to keep the connection open:

EDIT: Managed to keep the connection open

EDIT: Now the commands are sent but the spaces are not recognized.

EDIT: \u0020 made the space work but the param(login) it's not read

EDIT: Finally all it's working, \n was required at the string end.

import 'dart:io';
import 'dart:async';

const String user = "serveradmin";
const String pass = "------";

Socket socket;

void main() async {
    await Socket.connect("localhost", 10011)
        .then((Socket sock) {
        socket = sock;
        socket.listen(dataHandler,
            onError: errorHandler,
            onDone: doneHandler,
            cancelOnError: false);
    })
        .catchError((AsyncError e) {
        print("Unable to connect: $e");
        exit(1);
    });

    socket.write('help login\n');
    print("End main");

}

void dataHandler(data){
    print("Data Handler!");
    print(" ${new String.fromCharCodes(data).trim()}");
    socket.write(new String.fromCharCodes(data).trim() + 'help login');
}

void errorHandler(error, StackTrace trace){
    print(error);
}

void doneHandler(){
    print("Done Handler!");
    socket.destroy();
    exit(0);
}

Also seems like to login command it's not sent.

Mattia
  • 5,909
  • 3
  • 26
  • 41
  • You really should reconsider using telnet in 2018 IMHO... – ScottishTapWater Jul 13 '18 at 18:47
  • @JamesHughes teamspeak server query supports only that protocol – Mattia Jul 13 '18 at 18:49
  • It's not using telnet mate, it's using any character mode terminal... You should just be able to shoot commands at it's TCP port if you format it right. Take a look at this http://media.teamspeak.com/ts3_literature/TeamSpeak%203%20Server%20Query%20Manual.pdf – ScottishTapWater Jul 13 '18 at 18:52
  • Also, if you could use a .NET language rather than dash there are a tonne of libraries out there to help – ScottishTapWater Jul 13 '18 at 18:53
  • @JamesHughes What do you mean saying: `You should just be able to shoot commands at it's TCP port if you format it right.` How should I format the commands? to send and recive the replies(when I register the events) – Mattia Jul 13 '18 at 19:03
  • Honestly mate, I don't know Dash or Teamspeak, I just had a glance at the docs. Good luck! – ScottishTapWater Jul 13 '18 at 19:04
  • It's not clear what the current issue is after your edits, but if do you need a newline after sending `help login`? – Danny Tuppeny Jul 13 '18 at 21:27

0 Answers0