本文整理汇总了C#中Channel.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Channel.Update方法的具体用法?C# Channel.Update怎么用?C# Channel.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel.Update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Channel channel = new Channel();
HelloService service = new HelloService();
channel.AddMethod<HelloRequest, HelloSerializer>("maid.example.HelloService.HelloNotify", service.HelloNotify);
channel.AddMethod<HelloRequest, HelloSerializer, HelloResponse, HelloSerializer>("maid.example.HelloService.HelloRpc", service.HelloRpc);
channel.ConnectedCallback.Add(() =>
{
Console.WriteLine("连接上了");
});
channel.Connect("192.168.0.99", 8888);
while (true)
{
channel.Update();
HelloRequest request = new HelloRequest();
request.message = "this message from protobuf-net";
try
{
channel.CallMethod("maid.example.HelloService.HelloNotify", request);
channel.CallMethod("maid.example.HelloService.HelloRpc", request);
}
catch (Exception ){ }
if (channel.Connecting)
{
Console.WriteLine("连接中");
}
}
}
示例2: UpdateChannelService
private static void UpdateChannelService(Channel ch, Service s)
{
if (ch.Service == null || ch.Service.Id != s.Id)
{
if (ch == null)
{
Util.Trace(TraceLevel.Error, "Null channel object, service {0}!", s);
return;
}
if (ch.ChannelType == ChannelType.UserAdded)
{
Util.Trace(TraceLevel.Info, "Skipping service update for channel {0} because it is user added", ch);
return;
}
Util.Trace(TraceLevel.Warning, "Updating service for channel {0} to {1}", ch, s);
ch.Service = s;
ch.Update();
}
}
示例3: OrderingMoveUp
public void OrderingMoveUp(Channel channel)
{
IList<Channel> siblings = GetSiblings(channel);
Channel switcher =
siblings.Where(c => c.Ordering < channel.Ordering).OrderBy(c => c.Ordering).FirstOrDefault();
if (switcher != null)
{
int currentOrder = channel.Ordering;
channel.Ordering = switcher.Ordering;
switcher.Ordering = currentOrder;
channel.Update();
switcher.Update();
}
}