private Task SendAndExpect(ControlMessage messageToSend, BreweryMessageType responseExpected, int timeoutInSeconds) { DateTime timeoutAt = DateTime.Now + TimeSpan.FromSeconds(timeoutInSeconds); long firstSendAt = m_stopwatch.ElapsedTicks; return(Task.Run(() => { while (timeoutInSeconds == -1 || DateTime.Now < timeoutAt) { NetworkPump.Send(messageToSend); System.Threading.Thread.Sleep(1000); long ts = 0; if (m_receiptStamps.TryGetValue(responseExpected, out ts)) { if (ts >= firstSendAt) { break; } } } })); }
private Task SendAndExpect(ControlMessage messageToSend, BreweryMessageType responseExpected) { return(SendAndExpect(messageToSend, responseExpected, NetworkTimeout)); }
internal static Type GetMessageType(BreweryMessageType type) { return(EnumTypeToObjectType[type]); }