Niyazi Toros
2018-07-02 06:55:47 UTC
I can connect my aqueduct to close network socket (listener and get the
data) Problem is I can't return new Response.ok. It shows null...
I am using Aqueduct 3.0. The most of the documentation looks like Snippets.
I had difficulty to apply dart socket. But now I can get text from socket
and I can sent the data over internet from my aqueduct web api.
class LoginController extends Controller {
String _xCustomerToken;
String _xCustomerName;
var list = [];
@override
Future handle(Request request) async {
String reply;
Socket.connect('192.168.1.22â, 1024).then((socket) async {
socket.listen((data) async {
reply = await new String.fromCharCodes(data).trim();
print("reply: $reply");
var list = reply(":_:");
int cLen = list.length;
print(cLen);
print(list);
_xCustomerToken = list[2];
_xCustomerName = list[3];
// CAN PRINT THE SOCKET DATA
// EXAMPLE: âCustomer Token: 998877, CustomerName: NIYAZI TOROSâ
print(
"Customer Token: $_xCustomerToken, CustomerName: $_xCustomerName");
await new Future.delayed(new Duration(seconds: 2));
}, onDone: () {
print("Done");
});
socket.write('Q101:_:49785:_:x\r\n');
});
// CANT RETURN THE SOCKET DATA
return new Response.ok(
// EXAMPLE: "Customer Token: null, CustomerName: nullâ
"Customer Token: $_xCustomerToken, CustomerName: $_xCustomerName");
}
}
data) Problem is I can't return new Response.ok. It shows null...
I am using Aqueduct 3.0. The most of the documentation looks like Snippets.
I had difficulty to apply dart socket. But now I can get text from socket
and I can sent the data over internet from my aqueduct web api.
class LoginController extends Controller {
String _xCustomerToken;
String _xCustomerName;
var list = [];
@override
Future handle(Request request) async {
String reply;
Socket.connect('192.168.1.22â, 1024).then((socket) async {
socket.listen((data) async {
reply = await new String.fromCharCodes(data).trim();
print("reply: $reply");
var list = reply(":_:");
int cLen = list.length;
print(cLen);
print(list);
_xCustomerToken = list[2];
_xCustomerName = list[3];
// CAN PRINT THE SOCKET DATA
// EXAMPLE: âCustomer Token: 998877, CustomerName: NIYAZI TOROSâ
print(
"Customer Token: $_xCustomerToken, CustomerName: $_xCustomerName");
await new Future.delayed(new Duration(seconds: 2));
}, onDone: () {
print("Done");
});
socket.write('Q101:_:49785:_:x\r\n');
});
// CANT RETURN THE SOCKET DATA
return new Response.ok(
// EXAMPLE: "Customer Token: null, CustomerName: nullâ
"Customer Token: $_xCustomerToken, CustomerName: $_xCustomerName");
}
}
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/bd36643f-1a6f-4fe0-9669-4d59aeba5f4b%40dartlang.org.
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/bd36643f-1a6f-4fe0-9669-4d59aeba5f4b%40dartlang.org.