public AsyncRequest(Message request, TimeSpan timeout) { this.Request = request; this.WaitHandle = new ManualResetEvent(request.ServiceType != ServiceType.RequestResponse); this.ResponseCallback = new MessageReceivedHandler(this.ResponseReceived); this.TimeSpan = timeout; this.Start = CurrentTime.Now; this.Id = Guid.NewGuid().ToString(); }
public static IdentifiedMessage FromStream(Stream source) { IdentifiedMessage msg = null; byte msgType = (byte)source.ReadByte(); msgType = (byte)(msgType >> 1); if (msgType == 1) { msg = new Message(); } msg.Deserialize(source); return msg; }
private void ResponseReceived(object sender, Message message) { this.Response = message; this.WaitHandle.Set(); }