sendEventEmitterAck method

dynamic sendEventEmitterAck(
  1. dynamic method,
  2. dynamic data
)

send request emit to socket server and wait for response

Implementation

sendEventEmitterAck(method, data) async {
  log('sendRequestEmitterAck() [method: $method, data: $data]');
  final completer = Completer<dynamic>();
  final requestId = _socket.id;
  _socket.emitWithAck(
    'request',
    {
      'method': method,
      'data': data,
      'requestId': requestId,
    },
    ack: (response) {
      log('Event $method: $response');
      completer.complete(response[1]);
    },
  );
  return completer.future;
}