예제 #1
0
파일: SCAMPSOAClient.cs 프로젝트: xrl/scamp
        public override void Request(RequestLocalOptions opt, Message req, Action <Message> on_rpy)
        {
            string id;
            string is_closed;

            lock (state_lock) {
                id        = (nextid++).ToString();
                is_closed = closed_err;
                if (is_closed == null)
                {
                    pending [id] = new RequestInfo {
                        cb      = on_rpy,
                        timeout = new Timer((s) => {
                            RequestTimedOut(id);
                        }, null, (opt.Timeout + 5) * 1000, Timeout.Infinite),
                    };
                }
            }

            if (is_closed != null)
            {
                req.Discard();
                Message.StreamToCallback(on_rpy, new RPCException("transport", "Connection is closed", RPCException.DispatchFailure()).AsHeader());
            }
            else
            {
                req.Header ["request_id"] = id;
                req.Header ["type"]       = "request";
                p.SendMessage(req);
            }
        }
예제 #2
0
파일: Requester.cs 프로젝트: dnorman/scamp
        // the JS requestor uses a "forwardRequest" concept which is almost certainly a premature optimization and not duplicated here
        public static void MakeRequest(RequestLocalOptions opts, ActionName act, string envelope, Message req, Action<Message> on_rpy)
        {
            ServiceInfo si;
            ActionInfo ai;

            if (!discovery.FindService (act, envelope, opts.TargetIdent, out si, out ai)) {
                req.Discard ();
                Message.StreamToCallback (on_rpy, new RPCException ("transport", "Action {0} not found", act).AsHeader ());
                return;
            }

            // important: aliases are processed here
            req.Header ["action"] = ai.Name.Namespace + '.' + ai.Name.Name;
            req.Header ["version"] = (double)ai.Name.Version;

            SOAClient client;
            try {
                client = GetConnection (si);
            } catch (Exception ex) {
                RPCException rpcex = RPCException.Wrap (ex);
                req.Discard ();
                Message.StreamToCallback (on_rpy,
                    new RPCException ("transport", "Cannot establish connection", rpcex,
                        RPCException.DispatchFailure ()).AsHeader ());
                return;
            }

            if (opts.Timeout == 0)
                opts.Timeout = ai.Timeout;

            client.Request (opts, req, on_rpy);
        }
예제 #3
0
        public override void Request(RequestLocalOptions opt, Message req, Action<Message> on_rpy)
        {
            string id;
            string is_closed;
            lock (state_lock) {
                id = (nextid++).ToString ();
                is_closed = closed_err;
                if (is_closed == null) {
                    pending [id] = new RequestInfo {
                        cb = on_rpy,
                        timeout = new Timer ((s) => {
                            RequestTimedOut (id);
                        }, null, (opt.Timeout + 5) * 1000, Timeout.Infinite),
                    };
                }
            }

            if (is_closed != null) {
                req.Discard ();
                Message.StreamToCallback (on_rpy, new RPCException ("transport", "Connection is closed", RPCException.DispatchFailure ()).AsHeader ());
            } else {
                req.Header ["request_id"] = id;
                req.Header ["type"] = "request";
                p.SendMessage (req);
            }
        }
예제 #4
0
파일: Requester.cs 프로젝트: xrl/scamp
        // the JS requestor uses a "forwardRequest" concept which is almost certainly a premature optimization and not duplicated here
        static public void MakeRequest(RequestLocalOptions opts, ActionName act, string envelope, Message req, Action <Message> on_rpy)
        {
            ServiceInfo si;
            ActionInfo  ai;

            if (!discovery.FindService(act, envelope, opts.TargetIdent, out si, out ai))
            {
                req.Discard();
                Message.StreamToCallback(on_rpy, new RPCException("transport", "Action {0} not found", act).AsHeader());
                return;
            }

            // important: aliases are processed here
            req.Header ["action"]  = ai.Name.Namespace + '.' + ai.Name.Name;
            req.Header ["version"] = (double)ai.Name.Version;

            SOAClient client;

            try {
                client = GetConnection(si);
            } catch (Exception ex) {
                RPCException rpcex = RPCException.Wrap(ex);
                req.Discard();
                Message.StreamToCallback(on_rpy,
                                         new RPCException("transport", "Cannot establish connection", rpcex,
                                                          RPCException.DispatchFailure()).AsHeader());
                return;
            }

            if (opts.Timeout == 0)
            {
                opts.Timeout = ai.Timeout;
            }

            client.Request(opts, req, on_rpy);
        }
예제 #5
0
파일: SOAClient.cs 프로젝트: dnorman/scamp
 public abstract void Request(RequestLocalOptions opts, Message req, Action<Message> rpy);
예제 #6
0
 public abstract void Request(RequestLocalOptions opts, Message req, Action <Message> rpy);