private async Task HandleHeader(Header header) { if (!header.Values.ContainsKey("topic")) { throw new RosException("Header from subscriber did not have the required element: topic"); } string name = header.Values["topic"]; string clientCallerId = header.Values["callerid"]; Publication pt = TopicManager.Instance.LookupPublication(name); if (pt == null) { throw new RosException( $"Received a connection for a nonexistent topic [{name}] from [{connection.Socket.RemoteEndPoint}] [{clientCallerId}]"); } if (!pt.ValidateHeader(header, out string errorMessage)) { throw new RosException(errorMessage); } DestinationCallerId = clientCallerId; connectionId = ConnectionManager.Instance.GetNewConnectionId(); name = pt.Name; parent = pt; this.outbox = new AsyncQueue <MessageAndSerializerFunc>(Math.Max(parent.MaxQueue, 1), true); var m = new Dictionary <string, string> { ["type"] = pt.DataType, ["md5sum"] = pt.Md5Sum, ["message_definition"] = pt.MessageDefinition, ["callerid"] = ThisNode.Name, ["latching"] = Convert.ToString(pt.Latch) }; await connection.WriteHeader(m, cancel).ConfigureAwait(false); pt.AddSubscriberLink(this); logger.LogDebug("Finalize transport subscriber link for " + name); }
public void AddLocalConnection(Publication pub) { lock (gate) { if (IsDisposed) { return; } logger.LogInformation("Creating intraprocess link for topic [{0}]", Name); var pub_link = new LocalPublisherLink(this, XmlRpcManager.Instance.Uri); var sub_link = new LocalSubscriberLink(pub); pub_link.SetPublisher(sub_link); sub_link.SetSubscriber(pub_link); AddPublisherLink(pub_link); pub.AddSubscriberLink(sub_link); } }