private async Task <bool> AwaitResponse <TPayload>(string @event, Func <TPayload, bool> payloadCallback) { return(await Promises.Of <bool>((resolve) => { this.EventListener <TPayload>(@event, (payload) => { GD.Print($"Lan event {@event} received"); resolve(payloadCallback(payload)); }); GD.Print($"Waiting for lan event {@event}"); })); }