private async Task <ClientResponsePacketModel> SendAndListen(ClientPacketModelBase packet) { ClientResponsePacketModel replyPacket = null; this.replyIDListeners[packet.NormalRef] = null; await this.Send(packet); await this.WaitForSuccess(() => { if (this.replyIDListeners.ContainsKey(packet.NormalRef) && this.replyIDListeners[packet.NormalRef] != null) { replyPacket = this.replyIDListeners[packet.NormalRef]; return(true); } return(false); }, secondsToWait : 5); this.replyIDListeners.Remove(packet.NormalRef); return(replyPacket); }
private async Task Send(ClientPacketModelBase packet) { await this.Send(packet.ToSerializedPacketArray()); }