httpRequest method
Processes the HTTP request returning the HTTP response as a map
Implementation
@override
Future<Map<dynamic, dynamic>> httpRequest(
Uri? uri, Map<String, dynamic> request) {
final completer = Completer<Map<String, dynamic>>();
final webSocket = WebSocket(uri.toString());
final message = json.encode(request);
webSocket.onOpen.listen((Event e) {
webSocket.sendString(message);
});
webSocket.onError.listen((Event e) {
print('EthereumBrowserWSAdapter::WebSocket error, message not sent, '
'state is ${webSocket.readyState.toString()}');
webSocket.close();
completer.complete(<String, dynamic>{});
});
webSocket.onMessage.listen((MessageEvent e) {
final String ret = e.data;
webSocket.close();
completer.complete(json.decode(ret));
});
return completer.future;
}