import 'package:aqueduct/aqueduct.dart';
import 'package:niyaziapi/niyaziapi.dart';
import 'package:niyaziapi/util/niyaziprivate.dart';
class LoginController extends Controller {
@override
Future<RequestOrResponse> processRequest(Request request) async {
if (request.path.variables.containsKey('value')) {
var _xPrivate = (request.path.variables['value']).trim();
var tempData = await getPrivate(_xPrivate);
// TODO: Question-1: How to catch error if serevr is not reachable or down
var socket = await Socket.connect('192.168.1.22', 1024);
print("socket: $socket");
// TODO: Question-2: How to catch error when trying send data to socket
socket.write('$tempData\r\n');
// TODO: Question-3: How to catch error while socket listen (returning data)has error
await for (var data in socket) {
var reply = new String.fromCharCodes(data).trim();
// Do some heavy work in here then
return new Response.ok("$reply");
}
} else {
return new Response.ok("wrong rquest");
}
}
Future<String> getPrivate(_xPrivate) async {
// Do some heavy decryption in here then
return "data";
}
}UPDATE:when I testing I found that my code works. Only reason that I am sending 3DES data and has + and / character in it.
If you look at closely in first request, there is a + and / character in data which give me an error. /login/ziD7v0Ul99vmNWnxJRxZIiTY4zakNoq8GjM+oHROYz/YTHnd3NH1XfHRULY0jaHU 19ms 404
on the other hand if I remove those character than I get perfect response.
/login/ziD7v0Ul99vmNWnxJRxZIiTY4zakNoq8GjMoHROYzYTHnd3NH1XfHRULY0jaHU 13 ms 200So, question comes how to send encrypted (3DES) data into aqueduct without getting any error?
--
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+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/c9495b92-3ccd-498f-95ac-80a9453196b1%40dartlang.org.
var _xPrivate = request.path.remainingPath;
print("request: $_xPrivate");