handleIncomingEvent method
void
handleIncomingEvent(
- List eventJson,
- String url,
- dynamic message
)
Implementation
void handleIncomingEvent(List<dynamic> eventJson, String url, message) {
var id = eventJson[1];
if (globalState.inFlightRequests[id] == null) {
Logger.log.w(
"RECEIVED EVENT from $url for id $id, not in globalState inFlightRequests");
// send(url, jsonEncode(["CLOSE", id]));
return;
}
Nip01Event event = Nip01Event.fromJson(eventJson[2]);
if (!filterEvent(event)) {
return;
}
// check signature is valid
// if (!event.isIdValid) {
// Logger.log.e("RECEIVED $id INVALID EVENT $event");
// return;
// }
RequestState? state = globalState.inFlightRequests[id];
if (state != null) {
RelayRequestState? request = state.requests[url];
if (request != null) {
// request.eventIdsToBeVerified.add(event.id);
// eventVerifier.verify(event).then((validSig) {
// if (validSig) {
event.sources.add(url);
// event.validSig = true;
// if (relays[url] != null) {
// relays[url]!.incStatsByNewEvent(event, message.toString().codeUnits.length);
// }
if (state.networkController.isClosed) {
Logger.log.e(
"TRIED to add event to an already closed STREAM ${state.request.id} ${state.request.filters}");
} else {
state.networkController.add(event);
}
// } else {
// Logger.log.f("INVALID EVENT SIGNATURE: $event");
// }
// request.eventIdsToBeVerified.remove(event.id);
// closeIfAllEventsVerified(request, state, url);
// });
}
}
return;
}