Exemplo n.º 1
0
        protected bool RegisterRpcHandler(TaskCode code, string name, RpcRequestHandler handler, UInt64 gpid)
        {
            dsn_rpc_request_handler_t cb = (req, param) =>
            {
                // if handler synchnously processes the incoming request
                // we don't need to add_ref and set owner to true
                // in folloiwng two stmts
                // however, we don't know so we do as follows
                Native.dsn_msg_add_ref(req); // released by RpcReadStream
                var rms = new RpcReadStream(req, true);

                var wms = new RpcWriteStream(Native.dsn_msg_create_response(req));
                handler(rms, wms);
            };

            bool r = Native.dsn_rpc_register_handler(code, name, cb, IntPtr.Zero, gpid);

            Logging.dassert(r, "rpc handler registration failed for " + code.ToString());

            lock (_handlers)
            {
                _handlers.Add(code, cb);
            }
            return(true);
        }
Exemplo n.º 2
0
        protected bool RegisterRpcHandler(TaskCode code, string name, RpcRequestHandlerOneWay handler, UInt64 gpid)
        {
            dsn_rpc_request_handler_t cb = (req, param) =>
            {
                var rms = new RpcReadStream(req, false);
                handler(rms);
            };

            bool r = Native.dsn_rpc_register_handler(code, name, cb, IntPtr.Zero, gpid);

            Logging.dassert(r, "rpc handler registration failed for " + code.ToString());

            lock (_handlers)
            {
                _handlers.Add(code, cb);
            }
            return(r);
        }
Exemplo n.º 3
0
        protected bool RegisterRpcHandler(TaskCode code, string name, RpcRequestHandler handler)
        {
            dsn_rpc_request_handler_t cb = (dsn_message_t req, IntPtr param) =>
            {
                RpcReadStream  rms = new RpcReadStream(req, false);
                RpcWriteStream wms = new RpcWriteStream(Native.dsn_msg_create_response(req), false);
                handler(rms, wms);
            };

            bool r = Native.dsn_rpc_register_handler(code, name, cb, IntPtr.Zero);

            Logging.dassert(r, "rpc handler registration failed for " + code.ToString());

            lock (_handlers)
            {
                _handlers.Add(code, cb);
            }
            return(true);
        }