本文整理汇总了C#中Options.Address方法的典型用法代码示例。如果您正苦于以下问题:C# Options.Address方法的具体用法?C# Options.Address怎么用?C# Options.Address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options.Address方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public override void Start(Options options)
{
Logger.LogInformation($"Starting [{options.Id}]");
using (var socket = Context.CreatePullSocket())
{
socket.Bind(options.Address());
while (true)
{
// read a message
var message = socket.ReceiveFrameString();
Logger.LogDebug($"[{options.Id}] Received - {message}");
}
}
}
示例2: Start
public override void Start(Options options)
{
Logger.LogInformation($"Starting [{options.Id}]");
using (var socket = Context.CreateSubscriberSocket())
{
socket.Connect(options.Address());
socket.Subscribe(options.Topic); // if empty subscribes to all
while (true)
{
// read a message
var message = socket.ReceiveFrameString();
Logger.LogDebug($"[{options.Id}] Received - {message}");
}
}
}
示例3: Start
public override void Start(Options options)
{
Logger.LogInformation($"Starting [{options.Id}]");
using (var socket = Context.CreatePushSocket())
{
socket.Connect(options.Address());
var sw = Stopwatch.StartNew();
for (var i = 0; i < options.Messages; i++)
{
// write a message
socket.SendFrame($"Message: [{options.Id}] - {i}");
}
Logger.LogInformation($" [{options.Id}] - Sent {options.Messages} messages in: {sw.ElapsedMilliseconds} milliseconds");
}
}
示例4: Start
public override void Start(Options options)
{
Logger.LogInformation($"Starting [{options.Id}]");
using (var socket = Context.CreateResponseSocket())
{
socket.Bind(options.Address());
while (true)
{
// read a message
var message = socket.ReceiveFrameString();
Logger.LogDebug($"[{options.Id}] Received - {message}");
// reply with a response
socket.SendFrame($"Thanks for {message} from {options.Id}");
}
}
}
示例5: Start
public override void Start(Options options)
{
Logger.LogInformation($"Starting [{options.Id}]");
using (var socket = Context.CreatePublisherSocket())
{
socket.Bind(options.Address());
var sw = Stopwatch.StartNew();
var i = 0;
while(true)
{
// write some messages
socket.SendFrame($"Message A: [{options.Id}] - {i}");
socket.SendFrame($"Message B: [{options.Id}] - {i}");
i++;
Thread.Sleep(100);
}
}
}