private new static readonly Logger Logger = LogManager.CreateLogger(); // hide the Server.Logger so that tiny-logger can show the actual server as log source. public LogNetServer() { this.OnConnect += LogNetServer_OnConnect; this.OnDisconnect += LogNetServer_OnDisconnect; this.DataReceived += (sender, e) => LogNetRouter.Route(e); this.DataSent += (sender, e) => { }; }
/// <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++; if (!NO_RESPONSE.Equals(responsePrototype)) // if expected responce is NoResponse, don't add the call to rpc-callbacks list. { RPCCallbacks.Add(token, new RPCCallback(done, responsePrototype.WeakToBuilder())); } var packet = new PacketOut((byte)serviceId, LogNetRouter.GetMethodId(method), (uint)token, this._listenerId, request); this.Connection.Send(packet); }