/// <summary> /// 调用远程端实现的Api /// 并返回结果数据任务 /// </summary> /// <typeparam name="T">返回值类型</typeparam> /// <param name="api">数据包Api名</param> /// <param name="parameters">参数</param> /// <exception cref="SocketException"></exception> /// <exception cref="SerializerException"></exception> /// <returns>远程数据任务</returns> public ApiResult <T> InvokeApi <T>(string api, params object[] parameters) { var id = this.rpcServer.PacketIdProvider.NewId(); var packet = new FastPacket(api, id, false); packet.SetBodyParameters(this.rpcServer.Serializer, parameters); return(Common.InvokeApi <T>(this.channel, this.rpcServer.TaskSetterTable, this.rpcServer.Serializer, packet, this.rpcServer.TimeOut)); }
/// <summary> /// 调用远程端实现的Api /// </summary> /// <param name="api">数据包Api名</param> /// <param name="parameters">参数列表</param> /// <exception cref="SocketException"></exception> /// <exception cref="SerializerException"></exception> public void InvokeApi(string api, params object[] parameters) { var id = this.rpcServer.PacketIdProvider.NewId(); var packet = new FastPacket(api, id, false); packet.SetBodyParameters(this.rpcServer.Serializer, parameters); lock (this.channel) this.channel.WriteAndFlushAsync(packet); }