コード例 #1
0
ファイル: RpcExtensions.cs プロジェクト: resc/redpipes
 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;
 }
コード例 #2
0
ファイル: RpcExtensions.cs プロジェクト: resc/redpipes
 public Builder(IRpcProvider rpc, RpcOptions options, IBuilder <TResponse, TResponse> onResponse, IBuilder <TException, TException> onException)
 {
     _rpc         = rpc;
     _options     = options;
     _onResponse  = onResponse;
     _onException = onException;
 }
コード例 #3
0
ファイル: RpcExtensions.cs プロジェクト: resc/redpipes
 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>();
 }
コード例 #4
0
ファイル: RpcExtensions.cs プロジェクト: resc/redpipes
        /// <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));
        }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
        /// <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");
                }
            });
        }
コード例 #7
0
ファイル: RpcExtensions.cs プロジェクト: resc/redpipes
 /// <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));
 }
コード例 #8
0
 public RpcHub()
 {
     this.rpcProvider = DIService.Instance.GetService <IRpcProvider>();
 }
コード例 #9
0
 /// <summary>  </summary>
 public RpcClient(IRpcProvider provider, RpcOptions options)
 {
     Provider = provider;
     Options  = options;
 }
コード例 #10
0
ファイル: RpcService.cs プロジェクト: bebedard/Neuralium
 public RpcService(IRpcProvider rpcProvider, IServiceProvider serviceProvider)
 {
     this.rpcProvider            = (IRpcProvider <RPC_HUB, RCP_CLIENT>)rpcProvider;
     this.rpcProvider.RpcService = this;
     this.serviceProvider        = serviceProvider;
 }