internal void EnqueueSend(Message message, IPEndPoint endpoint) { lock (locker) { if (message.TransactionId == null) { if (message is ResponseMessage) { throw new ArgumentException("Message must have a transaction id"); } do { message.TransactionId = TransactionId.NextId(); } while (MessageFactory.IsRegistered(message.TransactionId)); } // We need to be able to cancel a query message if we time out waiting for a response if (message is QueryMessage) { MessageFactory.RegisterSend((QueryMessage)message); } sendQueue.Enqueue(new SendDetails(endpoint, message)); } }
internal void EnqueueSend(DhtMessage message, Node node, IPEndPoint endpoint, TaskCompletionSource <SendQueryEventArgs> tcs = null) { if (message.TransactionId == null) { if (message is ResponseMessage) { throw new ArgumentException("Message must have a transaction id"); } do { message.TransactionId = TransactionId.NextId(); } while (DhtMessageFactory.IsRegistered(message.TransactionId)); } // We need to be able to cancel a query message if we time out waiting for a response if (message is QueryMessage) { DhtMessageFactory.RegisterSend((QueryMessage)message); } SendQueue.Enqueue(new SendDetails(node, endpoint, message, tcs)); }