doRelayRequest method

bool doRelayRequest(
  1. String id,
  2. RelayRequestState request
)

Implementation

bool doRelayRequest(String id, RelayRequestState request) {
  if (_relayManager.isRelayConnected(request.url) &&
      (!_globalState.blockedRelays.contains(request.url))) {
    try {
      RelayConnectivity? relay = _globalState.relays[request.url];
      if (relay != null) {
        relay.stats.activeRequests++;
        _relayManager.send(
            relay,
            ClientMsg(
              ClientMsgType.REQ,
              id: id,
              filters: request.filters,
            ));
      }
      return true;
    } catch (e) {
      print(e);
    }
  } else {
    print(
        "COULD NOT SEND REQUEST TO ${request.url} since socket seems to be not open");
    RelayConnectivity? relay = _globalState.relays[request.url];
    if (relay != null) {
      _relayManager.reconnectRelay(relay.url,
          connectionSource: relay.relay.connectionSource);
    }
  }
  return false;
}