Ejemplo n.º 1
0
        protected override IP2pNet P2pNetFactory(string p2pConnectionString)
        {
            // P2pConnectionString is <p2p implmentation name>::<imp-dependent connection string>
            // Names are: p2ploopback, p2predis

            IP2pNet ip2p = null;

            string[] parts = p2pConnectionString.Split(new string[] { "::" }, StringSplitOptions.None); // Yikes! This is fugly.

            switch (parts[0])
            {
            case "p2predis":
                ip2p = new P2pRedis(this, parts[1]);
                break;

            case "p2ploopback":
                ip2p = new P2pLoopback(this, null);
                break;

            // case "p2pactivemq":
            //     p2p = new P2pActiveMq(this, parts[1]);
            //     break;
            default:
                throw(new Exception($"Invalid connection type: {parts[0]}"));
            }

            return(ip2p);
        }
Ejemplo n.º 2
0
        public void P2pShouldConnect()
        {
            TestClient tc  = new TestClient("jim", "meredith");
            IP2pNet    p2p = new P2pLoopback(tc, rawLoopbackConnectionStr);

            Assert.That(p2p, Is.Not.Null);
            Assert.That(p2p.GetId(), Is.Not.Null);
        }
Ejemplo n.º 3
0
        // Override this to account for P2pNet implementations you support
        protected virtual IP2pNet P2pNetFactory(string p2pConnectionString)
        {
            // P2pConnectionString is <p2p implmentation name>::<imp-dependent connection string>
            IP2pNet ip2p = null;

            string[] parts = p2pConnectionString.Split(new string[] { "::" }, StringSplitOptions.None); // Yikes! This is fugly.

            switch (parts[0].ToLower())
            {
            case "p2ploopback":
                ip2p = new P2pLoopback(this, null);
                break;

            default:
                throw(new Exception($"Invalid connection type: {parts[0]}"));
            }

            if (ip2p == null)
            {
                throw(new Exception("p2p Connect failed"));
            }

            return(ip2p);
        }