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.