private void SendSubscribeOperation(ROSBridgeSubscriber subscriber) { string s = ROSBridgeMsg.Subscribe(subscriber.Topic, ((IMsg)Activator.CreateInstance(subscriber.MessageType)).ROSMessageType); Debug.Log($"Sending: {s}"); _ws?.Send(s); }
private void SendUnSubscribeOperation(ROSBridgeSubscriber subscriber) { string s = ROSBridgeMsg.UnSubscribe(subscriber.Topic); Debug.Log($"Sending: {s}"); _ws?.Send(s); }
public ROSBridgeSubscriber <T> Subscribe <T>(string topic, ROSCallback <T> callback, int queueSize) where T : IMsg, new() { Type messageType = typeof(T); ThrowIfTopicExistsUnderDifferentType(topic, messageType, "subscribe"); ROSBridgeSubscriber subscriber; if (!subscribers.TryGetValue(topic, out subscriber)) { subscriber = new ROSBridgeSubscriber <T>(topic, queueSize); subscribers.Add(topic, subscriber); CacheTopic(topic, messageType); SendSubscribeOperation(subscriber); } var sub = (ROSBridgeSubscriber <T>)subscriber; sub.Subscribe(callback); return(sub); }