本文整理汇总了C#中IMessage.WeakToBuilder方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.WeakToBuilder方法的具体用法?C# IMessage.WeakToBuilder怎么用?C# IMessage.WeakToBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessage
的用法示例。
在下文中一共展示了IMessage.WeakToBuilder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallMethod
public void CallMethod(MethodDescriptor method, IRpcController controller, IMessage request, IMessage responsePrototype, Action<IMessage> done)
{
uint hash = method.Service.GetHash();
ExternalService externalService = exportedServicesIds[hash];
var requestId = externalService.GetNextRequestId();
callbacks.Enqueue(new Callback { Action = done, Builder = responsePrototype.WeakToBuilder(), RequestId = requestId });
ServerPacket data = new ServerPacket(externalService.Id, (int)GetMethodId(method), requestId, ListenerId).WriteMessage(request);
Send(data);
}
示例2: CallMethod
/// <summary>
/// Makes an RPC over remote client.
/// </summary>
/// <param name="method">The method to call.</param>
/// <param name="controller">The rpc controller.</param>
/// <param name="request">The request message.</param>
/// <param name="responsePrototype">The response message.</param>
/// <param name="done">Action to run when client responds RPC.</param>
public void CallMethod(MethodDescriptor method, IRpcController controller, IMessage request, IMessage responsePrototype, Action<IMessage> done)
{
var serviceName = method.Service.FullName;
var serviceHash = StringHashHelper.HashIdentity(serviceName);
if (!this.Services.ContainsKey(serviceHash))
{
Logger.Error("Not bound to client service {0} [0x{1}] yet.", serviceName, serviceHash.ToString("X8"));
return;
}
var serviceId = this.Services[serviceHash];
var token = this._tokenCounter++;
RPCCallbacks.Add(token, new RPCCallback(done, responsePrototype.WeakToBuilder()));
var packet = new PacketOut((byte)serviceId, MooNetRouter.GetMethodId(method), (uint)token, this._listenerId, request);
this.Connection.Send(packet);
}