Пример #1
0
 static ReqrepManager()
 {
     SenderFactory.Register("replystate", LookupReplyStateByUri);
     _inst_tab_sync = new object();
     lock (_inst_tab_sync) {
         _instance_table = new WeakValueTable <string, ReqrepManager>();
     }
 }
Пример #2
0
 static ReqrepManager()
 {
     SenderFactory.Register("replystate", LookupReplyStateByUri);
     _inst_tab_sync = new object();
     lock (_inst_tab_sync) {
         _instance_table = new Dictionary <object, ReqrepManager>();
     }
 }
Пример #3
0
        public System.String ToUri()
        {
            var kv = new SCG.Dictionary <string, string>();

            kv["wrap"] = _wrapped_sender.ToUri();
            kv["max"]  = MAX_PAYLOAD_SIZE.ToString();
            return(SenderFactory.EncodeUri("frag", kv));
        }
Пример #4
0
        public void EqTest()
        {
            var fp  = FragPipe.Instance; //Get some sender
            var fs1 = new FragmentingSender(100, fp);
            var fs2 = new FragmentingSender(100, fp);

            Assert.AreEqual(fs1, fs2);
            Assert.AreEqual(fs1.GetHashCode(), fs2.GetHashCode());
            //urlencode sender:pipe
            Assert.AreEqual(fs1.ToUri(), "sender:frag?max=100&wrap=sender%3apipe");
            Assert.AreEqual(fs1, SenderFactory.CreateInstance(null, fs1.ToUri()), "uri RT");
        }
Пример #5
0
            public string ToUri()
            {
                string uri;

                if (_uri.TryGet(out uri) == false)
                {
                    Dictionary <string, string> kvpairs = new Dictionary <string, string>();
                    kvpairs["id"]      = LocalID.ToString();
                    kvpairs["retpath"] = RequestKey.Sender.ToUri();
                    uri = SenderFactory.EncodeUri("replystate", kvpairs);
                    _uri.TrySet(uri);
                }
                return(uri);
            }
Пример #6
0
        public static ReplyState LookupReplyStateByUri(object ctx, string uri)
        {
            ReqrepManager rrm = _instance_table[ctx];
            string        scheme;
            IDictionary <string, string> kvpairs = SenderFactory.DecodeUri(uri, out scheme);
            int        id = Int32.Parse(kvpairs["id"]);
            ReplyState rs;

            if (rrm._reply_id_table.TryGet(id, out rs))
            {
                return(rs);
            }
            else
            {
                throw new Exception(String.Format("Invalid id: {0}", id));
            }
        }
Пример #7
0
        public static ISender CreateInstance(object ctx, string uri)
        {
            string scheme;
            var    kv = SenderFactory.DecodeUri(uri, out scheme);

            if (scheme.Equals("frag"))
            {
                int     max     = System.Int32.Parse(kv["max"]);
                string  wuri    = kv["wrap"];
                ISender wrapped = SenderFactory.CreateInstance(ctx, wuri);
                return(new FragmentingSender(max, wrapped));
            }
            else
            {
                throw new System.Exception("Unrecognized scheme: " + scheme);
            }
        }
Пример #8
0
 static FragmentingSender()
 {
     SenderFactory.Register("frag", CreateInstance);
 }
Пример #9
0
 static FragPipe()
 {
     SenderFactory.Register("pipe", delegate(object o, string uri) { return
                                                                     (Instance); });
 }