public Pipe([NotNull] IRpcProvider rpc, [NotNull] RpcOptions options, [NotNull] IPipe <TResponse> onResponse, IPipe <TException>?onException = null) { _rpc = rpc ?? throw new ArgumentNullException(nameof(rpc)); _options = options ?? throw new ArgumentNullException(nameof(options)); _onResponse = onResponse ?? throw new ArgumentNullException(nameof(onResponse)); _onException = onException; }
public Builder(IRpcProvider rpc, RpcOptions options, IBuilder <TResponse, TResponse> onResponse, IBuilder <TException, TException> onException) { _rpc = rpc; _options = options; _onResponse = onResponse; _onException = onException; }
public RpcPipeBuilder(IBuilder <TIn, TRequest> builder, IRpcProvider provider, RpcOptions?options = null, IBuilder <TResponse, TResponse>?responsePipeBuilder = null) { _builder = builder; _provider = provider; _options = options ?? new RpcOptions(); _responsePipeBuilder = responsePipeBuilder ?? Pipe.Builder <TResponse>(); }
/// <summary> </summary> public static IContext WithRpcProvider(this IContext ctx, [NotNull] IRpcProvider provider) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } return(ctx.With(_rpcProviderKey, provider)); }
private static void SubscribeTokens <TAttr>(IRpcProvider provider, IEnumerable <KeyValuePair <byte?, TAttr> > tokens, Action <NetMessage> del) where TAttr : Attribute, IRpcAttribute { foreach (var token in tokens) { if (token.Value == null) { continue; } provider.SubscribeToRpc(token.Value.RpcId, del); } }
/// <summary> /// Subscribe TAttr marked methods on obj to the provider /// </summary> /// <typeparam name="TAttr">Attribute type</typeparam> /// <param name="provider"></param> /// <param name="obj"></param> /// <param name="serializer"></param> /// <param name="logger"></param> public static void SubscribeObject <TAttr>(IRpcProvider provider, object obj, SerializationManager serializer, ILogger logger) where TAttr : Attribute, IRpcAttribute { if (obj == null) { return; } if (provider == obj) { return; } var objType = obj.GetType(); //logger.Info("Subscribing " + obj); ForEachRpc <TAttr>(objType, (method, parms, parmTypes, tokens) => { var msgDel = Delegate.CreateDelegate(typeof(Action <NetMessage>), obj, method, false) as Action <NetMessage>; if (msgDel != null) { SubscribeTokens(provider, tokens, msgDel); } else if (method.ReturnType == typeof(void)) { //the function isn't a deserializer function, so attempt to make our own from INetSerializable/default serializers if (!CheckParameterSerialization <BadInfoType>(serializer, method, parms, logger)) { return; } DynamicMethodDelegate pre; RpcCallers.TryGetValue(method.MethodHandle, out pre); //prevent the open delegate from needing a reference to this networkview? var deser = new RpcDeserializer <BadInfoType>(method, obj, serializer, parmTypes, @delegate: pre); msgDel = deser.Message; SubscribeTokens(provider, tokens, msgDel); } else { //method returns something, so it's a func processor logger.Error("Cannot subscribe method with a return type other than void"); } }); }
/// <summary> </summary> public static IOnRpcResponse <TIn, TRequest> WithRpcProvider <TIn, TRequest>(this IBuilder <TIn, TRequest> builder, IRpcProvider provider, RpcOptions?options = null) { return(new RpcPipeBuilder <TIn, TRequest, Exception>(builder, provider, options)); }
public RpcHub() { this.rpcProvider = DIService.Instance.GetService <IRpcProvider>(); }
/// <summary> </summary> public RpcClient(IRpcProvider provider, RpcOptions options) { Provider = provider; Options = options; }
public RpcService(IRpcProvider rpcProvider, IServiceProvider serviceProvider) { this.rpcProvider = (IRpcProvider <RPC_HUB, RCP_CLIENT>)rpcProvider; this.rpcProvider.RpcService = this; this.serviceProvider = serviceProvider; }