本文整理汇总了C#中Publisher.AddTopic方法的典型用法代码示例。如果您正苦于以下问题:C# Publisher.AddTopic方法的具体用法?C# Publisher.AddTopic怎么用?C# Publisher.AddTopic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publisher
的用法示例。
在下文中一共展示了Publisher.AddTopic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTopic_MultipleTopicSuccess
public void AddTopic_MultipleTopicSuccess()
{
MRosTopicClient<std_msgs.String>.AllInstances.StartAsyncSocketBoolean =
(t1, t2, t3) => Task<IObservable<byte[]>>.Factory.StartNew(Observable.Empty<byte[]>);
MRosTopicClient<std_msgs.String>.AllInstances.SendAsyncTMessage =
(t1, t2) => Task.Factory.StartNew(() => t2.SerializeLength);
var sock1 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var sock2 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var pub = new Publisher<std_msgs.String>("test", "testnode");
pub.AddTopic(sock1).Wait();
pub.AddTopic(sock2).Wait();
pub.OnNext(new std_msgs.String() { data = "test" });
pub.OnNext(new std_msgs.String() { data = "test" });
pub.OnNext(new std_msgs.String() { data = "test" });
}
示例2: AddTopic_Success
public void AddTopic_Success()
{
MRosTopicClient<std_msgs.String>.AllInstances.StartAsyncSocketBoolean = (t1, t2, t3) => Task<IObservable<byte[]>>.Factory.StartNew(Observable.Empty<byte[]>);
var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var pub = new Publisher<std_msgs.String>("test", "testnode");
pub.AddTopic(sock).Wait();
}
示例3: AddTopic_Error
public void AddTopic_Error()
{
MRosTopicClient<std_msgs.String>.AllInstances.StartAsyncSocketBoolean =
(t1, t2, t3) => Task<IObservable<byte[]>>.Factory.StartNew(() => { throw new InvalidOperationException("Start Error"); });
var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var pub = new Publisher<std_msgs.String>("test", "testnode");
var ex = AssertEx.Throws<AggregateException>(() => pub.AddTopic(sock).Wait());
//ex.InnerException.GetType().Is(typeof(InvalidOperationException));
}