Exemplo n.º 1
0
 getConnectionObserver(Ice.ConnectionInfo ci,
                       Ice.Endpoint ei,
                       Ice.Instrumentation.ConnectionState s,
                       Ice.Instrumentation.ConnectionObserver o)
 {
     return(null);
 }
Exemplo n.º 2
0
        public void setLookupReply(LookupReplyPrx lookupReply)
        {
            //
            // Use a lookup reply proxy whose adress matches the interface used to send multicast datagrams.
            //
            var single = new Ice.Endpoint[1];

            foreach (var key in new List <LookupPrx>(_lookups.Keys))
            {
                var info = (Ice.UDPEndpointInfo)key.Endpoints[0].getInfo();
                if (info.mcastInterface.Length > 0)
                {
                    foreach (var q in lookupReply.Endpoints)
                    {
                        var r = q.getInfo();
                        if (r is Ice.IPEndpointInfo && ((Ice.IPEndpointInfo)r).host.Equals(info.mcastInterface))
                        {
                            single[0]     = q;
                            _lookups[key] = lookupReply.Clone(endpoints: single);
                        }
                    }
                }

                if (_lookups[key] == null)
                {
                    // Fallback: just use the given lookup reply proxy if no matching endpoint found.
                    _lookups[key] = lookupReply;
                }
            }
        }
Exemplo n.º 3
0
 public ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state)
     : base(_attributes)
 {
     _connectionInfo = con;
     _endpoint       = endpt;
     _state          = state;
 }
Exemplo n.º 4
0
 public RemoteInvocationHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, int requestId, int size) :
     base(_attributes)
 {
     _connectionInfo = con;
     _endpoint       = endpt;
     _requestId      = requestId;
     _size           = size;
 }
Exemplo n.º 5
0
 public override bool Equivalent(Ice.Endpoint endpoint)
 {
     if (endpoint is Endpoint testEndpoint)
     {
         return(testEndpoint._endpoint.Equivalent(_endpoint));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 6
0
 public override Ice.Endpoint NewConnectionId(string connectionId)
 {
     Ice.Endpoint endpoint = _endpoint.NewConnectionId(connectionId);
     if (endpoint == _endpoint)
     {
         return(this);
     }
     else
     {
         return(new Endpoint(endpoint));
     }
 }
Exemplo n.º 7
0
 getRemoteObserver(Ice.ConnectionInfo c, Ice.Endpoint e, int a, int b)
 {
     lock (this)
     {
         if (remoteObserver == null)
         {
             remoteObserver = new RemoteObserverI();
             remoteObserver.reset();
         }
         return(remoteObserver);
     }
 }
Exemplo n.º 8
0
 getConnectionEstablishmentObserver(Ice.Endpoint e, String s)
 {
     lock (this)
     {
         if (connectionEstablishmentObserver == null)
         {
             connectionEstablishmentObserver = new ObserverI();
             connectionEstablishmentObserver.reset();
         }
         return(connectionEstablishmentObserver);
     }
 }
Exemplo n.º 9
0
 getEndpointLookupObserver(Ice.Endpoint e)
 {
     lock (this)
     {
         if (endpointLookupObserver == null)
         {
             endpointLookupObserver = new ObserverI();
             endpointLookupObserver.reset();
         }
         return(endpointLookupObserver);
     }
 }
Exemplo n.º 10
0
 public override Ice.Endpoint NewCompressionFlag(bool compressionFlag)
 {
     Ice.Endpoint endpoint = _endpoint.NewCompressionFlag(compressionFlag);
     if (endpoint == _endpoint)
     {
         return(this);
     }
     else
     {
         return(new Endpoint(endpoint));
     }
 }
Exemplo n.º 11
0
 getConnectionObserver(Ice.ConnectionInfo c,
                       Ice.Endpoint e,
                       Ice.Instrumentation.ConnectionState s,
                       Ice.Instrumentation.ConnectionObserver old)
 {
     lock (this)
     {
         Debug.Assert(old == null || old is ConnectionObserverI);
         if (connectionObserver == null)
         {
             connectionObserver = new ConnectionObserverI();
             connectionObserver.reset();
         }
         return(connectionObserver);
     }
 }
Exemplo n.º 12
0
        LocatorI(string name, LookupPrx lookup, Properties properties, string instanceName, LocatorPrx voidLocator)
        {
            _lookup  = lookup;
            _timeout = properties.getPropertyAsIntWithDefault(name + ".Timeout", 300);
            if (_timeout < 0)
            {
                _timeout = 300;
            }
            _retryCount = properties.getPropertyAsIntWithDefault(name + ".RetryCount", 3);
            if (_retryCount < 0)
            {
                _retryCount = 0;
            }
            _retryDelay = properties.getPropertyAsIntWithDefault(name + ".RetryDelay", 2000);
            if (_retryDelay < 0)
            {
                _retryDelay = 0;
            }
            _timer             = lookup.Communicator.timer();
            _traceLevel        = properties.getPropertyAsInt(name + ".Trace.Lookup");
            _instanceName      = instanceName;
            _warned            = false;
            _locator           = lookup.Communicator.getDefaultLocator();
            _voidLocator       = voidLocator;
            _pending           = false;
            _pendingRetryCount = 0;
            _failureCount      = 0;
            _warnOnce          = true;

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Ice.Endpoint[1];

            foreach (var endpt in lookup.Endpoints)
            {
                single[0] = endpt;
                _lookups[lookup.Clone(endpoints: single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Exemplo n.º 13
0
 public Ice.Instrumentation.Observer getEndpointLookupObserver(Ice.Endpoint endpt)
 {
     if (_endpointLookups.isEnabled())
     {
         try
         {
             Ice.Instrumentation.Observer del = null;
             if (_delegate != null)
             {
                 del = _delegate.getEndpointLookupObserver(endpt);
             }
             return(_endpointLookups.getObserver(new EndpointHelper(endpt), del));
         }
         catch (System.Exception ex)
         {
             _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex);
         }
     }
     return(null);
 }
Exemplo n.º 14
0
        public LookupI(LocatorRegistryI registry, LookupPrx lookup, Ice.Communicator communicator)
        {
            _registry          = registry;
            _lookup            = lookup;
            _timeout           = communicator.GetPropertyAsInt("IceDiscovery.Timeout") ?? 300;
            _retryCount        = communicator.GetPropertyAsInt("IceDiscovery.RetryCount") ?? 3;
            _latencyMultiplier = communicator.GetPropertyAsInt("IceDiscovery.LatencyMultiplier") ?? 1;
            _domainId          = communicator.GetProperty("IceDiscovery.DomainId") ?? "";
            _timer             = lookup.Communicator.timer();

            //
            // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast
            // datagram on each endpoint.
            //
            var single = new Ice.Endpoint[1];

            foreach (var endpt in lookup.Endpoints)
            {
                single[0] = endpt;
                _lookups[lookup.Clone(endpoints: single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Exemplo n.º 15
0
 public Ice.Instrumentation.ConnectionObserver getConnectionObserver(Ice.ConnectionInfo c,
                                                                     Ice.Endpoint e,
                                                                     Ice.Instrumentation.ConnectionState s,
                                                                     Ice.Instrumentation.ConnectionObserver obsv)
 {
     if (_connections.isEnabled())
     {
         try
         {
             Ice.Instrumentation.ConnectionObserver del = null;
             ConnectionObserverI o = obsv is ConnectionObserverI ? (ConnectionObserverI)obsv : null;
             if (_delegate != null)
             {
                 del = _delegate.getConnectionObserver(c, e, s, o != null ? o.getDelegate() : obsv);
             }
             return(_connections.getObserver(new ConnectionHelper(c, e, s), obsv, del));
         }
         catch (System.Exception ex)
         {
             _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex);
         }
     }
     return(null);
 }
Exemplo n.º 16
0
 getEndpointLookupObserver(Ice.Endpoint e)
 {
     return(null);
 }
Exemplo n.º 17
0
 public EndpointHelper(Ice.Endpoint endpt) : base(_attributes)
 {
     _endpoint = endpt;
 }
Exemplo n.º 18
0
 public EndpointHelper(Ice.Endpoint endpt, string id) : base(_attributes)
 {
     _endpoint = endpt;
     _id       = id;
 }
Exemplo n.º 19
0
 internal WSEndpoint(TransportInstance instance, Endpoint del, string res)
 {
     _instance = instance;
     _delegate = del;
     Resource  = res;
 }
Exemplo n.º 20
0
    public static TestIntfPrx allTests(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.communicator();
        Write("testing stringToProxy... ");
        Flush();
        string @ref = "test:" + app.getTestEndpoint(0);

        Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
        test(@base != null);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);

        test(obj != null);
        test(obj.Equals(@base));
        WriteLine("ok");

        {
            Write("creating/destroying/recreating object adapter... ");
            Flush();
            Ice.ObjectAdapter adapter =
                communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
            try
            {
                communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
                test(false);
            }
            catch (Ice.AlreadyRegisteredException)
            {
            }
            adapter.destroy();

            //
            // Use a different port than the first adapter to avoid an "address already in use" error.
            //
            adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
            adapter.destroy();
            Console.Out.WriteLine("ok");
        }

        Write("creating/activating/deactivating object adapter in one operation... ");
        Flush();
        obj.transient();
        obj.end_transient(obj.begin_transient());
        WriteLine("ok");

        {
            Write("testing connection closure... ");
            Flush();
            for (int i = 0; i < 10; ++i)
            {
                Ice.InitializationData initData = new Ice.InitializationData();
                initData.properties = communicator.getProperties().ice_clone_();
                Ice.Communicator comm = Ice.Util.initialize(initData);
                comm.stringToProxy("test:" + app.getTestEndpoint(0)).begin_ice_ping();
                comm.destroy();
            }
            WriteLine("ok");
        }

        Write("testing object adapter published endpoints... ");
        Flush();
        {
            communicator.getProperties().setProperty("PAdapter.PublishedEndpoints", "tcp -h localhost -p 12345 -t 30000");
            Ice.ObjectAdapter adapter = communicator.createObjectAdapter("PAdapter");
            test(adapter.getPublishedEndpoints().Length == 1);
            Ice.Endpoint endpt = adapter.getPublishedEndpoints()[0];
            test(endpt.ToString().Equals("tcp -h localhost -p 12345 -t 30000"));
            Ice.ObjectPrx prx =
                communicator.stringToProxy("dummy:tcp -h localhost -p 12346 -t 20000:tcp -h localhost -p 12347 -t 10000");
            adapter.setPublishedEndpoints(prx.ice_getEndpoints());
            test(adapter.getPublishedEndpoints().Length == 2);
            Ice.Identity id = new Ice.Identity();
            id.name = "dummy";
            test(IceUtilInternal.Arrays.Equals(adapter.createProxy(id).ice_getEndpoints(), prx.ice_getEndpoints()));
            test(IceUtilInternal.Arrays.Equals(adapter.getPublishedEndpoints(), prx.ice_getEndpoints()));
            adapter.refreshPublishedEndpoints();
            test(adapter.getPublishedEndpoints().Length == 1);
            test(adapter.getPublishedEndpoints()[0].Equals(endpt));
            communicator.getProperties().setProperty("PAdapter.PublishedEndpoints", "tcp -h localhost -p 12345 -t 20000");
            adapter.refreshPublishedEndpoints();
            test(adapter.getPublishedEndpoints().Length == 1);
            test(adapter.getPublishedEndpoints()[0].ToString().Equals("tcp -h localhost -p 12345 -t 20000"));
            adapter.destroy();
            test(adapter.getPublishedEndpoints().Length == 0);
        }
        WriteLine("ok");

        if (obj.ice_getConnection() != null)
        {
            Write("testing object adapter with bi-dir connection... ");
            Flush();
            Ice.ObjectAdapter adapter = communicator.createObjectAdapter("");
            obj.ice_getConnection().setAdapter(adapter);
            obj.ice_getConnection().setAdapter(null);
            adapter.deactivate();
            try
            {
                obj.ice_getConnection().setAdapter(adapter);
                test(false);
            }
            catch (Ice.ObjectAdapterDeactivatedException)
            {
            }
            WriteLine("ok");
        }

        Write("testing object adapter with router... ");
        Flush();
        {
            Ice.Identity routerId = new Ice.Identity();
            routerId.name = "router";
            Ice.RouterPrx     router  = Ice.RouterPrxHelper.uncheckedCast(@base.ice_identity(routerId).ice_connectionId("rc"));
            Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithRouter("", router);
            test(adapter.getPublishedEndpoints().Length == 1);
            test(adapter.getPublishedEndpoints()[0].ToString().Equals("tcp -h localhost -p 23456 -t 30000"));
            adapter.refreshPublishedEndpoints();
            test(adapter.getPublishedEndpoints().Length == 1);
            test(adapter.getPublishedEndpoints()[0].ToString().Equals("tcp -h localhost -p 23457 -t 30000"));
            try
            {
                adapter.setPublishedEndpoints(router.ice_getEndpoints());
                test(false);
            }
            catch (ArgumentException)
            {
                // Expected.
            }
            adapter.destroy();

            try
            {
                routerId.name = "test";
                router        = Ice.RouterPrxHelper.uncheckedCast(@base.ice_identity(routerId));
                communicator.createObjectAdapterWithRouter("", router);
                test(false);
            }
            catch (Ice.OperationNotExistException)
            {
                // Expected: the "test" object doesn't implement Ice::Router!
            }

            try
            {
                router = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("test:" + app.getTestEndpoint(1)));
                communicator.createObjectAdapterWithRouter("", router);
                test(false);
            }
            catch (Ice.ConnectFailedException)
            {
            }
        }
        WriteLine("ok");

        Write("testing object adapter creation with port in use... ");
        Flush();
        {
            var adapter1 = communicator.createObjectAdapterWithEndpoints("Adpt1", app.getTestEndpoint(10));
            try
            {
                communicator.createObjectAdapterWithEndpoints("Adpt2", app.getTestEndpoint(10));
                test(false);
            }
            catch (Ice.LocalException)
            {
                // Expected can't re-use the same endpoint.
            }
            adapter1.destroy();
        }
        WriteLine("ok");

        Write("deactivating object adapter in the server... ");
        Flush();
        obj.deactivate();
        WriteLine("ok");

        Write("testing whether server is gone... ");
        Flush();
        try
        {
            obj.ice_timeout(100).ice_ping(); // Use timeout to speed up testing on Windows
            test(false);
        }
        catch (Ice.LocalException)
        {
            WriteLine("ok");
        }

        return(obj);
    }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a new proxy that is identical to this proxy, except for the endpoints.
 /// </summary>
 /// <param name="newEndpoints">The endpoints for the new proxy.</param>
 /// <returns>The proxy with the new endpoints.</returns>
 public ObjectPrx ice_endpoints(Endpoint[] newEndpoints)
 {
     if(Arrays.Equals(newEndpoints, _reference.getEndpoints()))
     {
         return this;
     }
     else
     {
         IceInternal.EndpointI[] endpts = new IceInternal.EndpointI[newEndpoints.Length];
         for(int i = 0; i < newEndpoints.Length; ++i)
         {
             endpts[i] = (IceInternal.EndpointI)newEndpoints[i];
         }
         return newInstance(_reference.changeEndpoints(endpts));
     }
 }
Exemplo n.º 22
0
 internal Endpoint(Ice.Endpoint endpoint)
 {
     _endpoint      = endpoint;
     _configuration = Configuration.GetInstance();
 }
Exemplo n.º 23
0
 internal Endpoint GetEndpoint(Ice.Endpoint del) => del == _endpoint ? this : new Endpoint(del);
Exemplo n.º 24
0
 protected override Endpoint CreateWithUnderlying(Endpoint underlying, string endpointString,
                                                  Dictionary <string, string?> options, bool oaEndpoint) =>
 new WSEndpoint(Instance, underlying, endpointString, options);
Exemplo n.º 25
0
 protected override Endpoint ReadWithUnderlying(Endpoint underlying, Ice.InputStream s) =>
 new WSEndpoint(Instance, underlying, s);
Exemplo n.º 26
0
 getConnectionEstablishmentObserver(Ice.Endpoint e, string s)
 {
     return(null);
 }
Exemplo n.º 27
0
 internal WSEndpoint GetEndpoint(Endpoint del) =>
 del == _delegate ? this : new WSEndpoint(_instance, del, Resource);
Exemplo n.º 28
0
 public Ice.Instrumentation.RemoteObserver getRemoteObserver(Ice.ConnectionInfo con, Ice.Endpoint endpt,
                                                             int requestId, int size)
 {
     Ice.Instrumentation.RemoteObserver del = null;
     if (delegate_ != null)
     {
         del = delegate_.getRemoteObserver(con, endpt, requestId, size);
     }
     return(getObserver <RemoteMetrics, RemoteObserverI,
                         Ice.Instrumentation.RemoteObserver>("Remote",
                                                             new RemoteInvocationHelper(con, endpt, requestId, size),
                                                             del));
 }
Exemplo n.º 29
0
 public virtual void WriteEndpoint (Endpoint e) {
   if (e is TcpEndpoint) {
     TcpEndpoint te = e as TcpEndpoint;
     Write ((short) 1);      // Endpoint Type
     BeginEncapsulation ();
     Write (te.host);
     Write (te.port);
     Write (te.timeout);
     Write (te.compress);
     EndEncapsulation ();
   } else if (e is SslEndpoint) {
     SslEndpoint se = e as SslEndpoint;
     Write ((short) 2);      // Endpoint Type
     BeginEncapsulation ();
     Write (se.host);
     Write (se.port);
     Write (se.timeout);
     Write (se.compress);
     EndEncapsulation ();
   } else if (e is UdpEndpoint) {
     UdpEndpoint ue = e as UdpEndpoint;
     Write ((short) 3);      // Endpoint Type
     BeginEncapsulation ();
     Write (ue.host);
     Write (ue.port);
     Write (ue.protocolMajor);
     Write (ue.protocolMinor);
     Write (ue.encodingMajor);
     Write (ue.encodingMinor);
     Write (ue.compress);
     EndEncapsulation();
   }
 }
Exemplo n.º 30
0
    public static void allTests(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.communicator();
        Write("testing proxy endpoint information... ");
        Flush();
        {
            Ice.ObjectPrx p1 = communicator.stringToProxy(
                "test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" +
                "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" +
                "opaque -e 1.8 -t 100 -v ABCD");

            Ice.Endpoint[] endps = p1.ice_getEndpoints();

            Ice.EndpointInfo    info        = endps[0].getInfo();
            Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(info);
            test(tcpEndpoint.host.Equals("tcphost"));
            test(tcpEndpoint.port == 10000);
            test(tcpEndpoint.sourceAddress.Equals("10.10.10.10"));
            test(tcpEndpoint.timeout == 1200);
            test(tcpEndpoint.compress);
            test(!tcpEndpoint.datagram());

            test(tcpEndpoint.type() == Ice.TCPEndpointType.value && !tcpEndpoint.secure() ||
                 tcpEndpoint.type() == Ice.SSLEndpointType.value && tcpEndpoint.secure() ||
                 tcpEndpoint.type() == Ice.WSEndpointType.value && !tcpEndpoint.secure() ||
                 tcpEndpoint.type() == Ice.WSSEndpointType.value && tcpEndpoint.secure());
            test(tcpEndpoint.type() == Ice.TCPEndpointType.value && info is Ice.TCPEndpointInfo ||
                 tcpEndpoint.type() == Ice.SSLEndpointType.value && info is IceSSL.EndpointInfo ||
                 tcpEndpoint.type() == Ice.WSEndpointType.value && info is Ice.WSEndpointInfo ||
                 tcpEndpoint.type() == Ice.WSSEndpointType.value && info is Ice.WSEndpointInfo);

            Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endps[1].getInfo();
            test(udpEndpoint.host.Equals("udphost"));
            test(udpEndpoint.port == 10001);
            test(udpEndpoint.mcastInterface.Equals("eth0"));
            test(udpEndpoint.mcastTtl == 5);
            test(udpEndpoint.sourceAddress.Equals("10.10.10.10"));
            test(udpEndpoint.timeout == -1);
            test(!udpEndpoint.compress);
            test(!udpEndpoint.secure());
            test(udpEndpoint.datagram());
            test(udpEndpoint.type() == 3);

            Ice.OpaqueEndpointInfo opaqueEndpoint = (Ice.OpaqueEndpointInfo)endps[2].getInfo();
            test(opaqueEndpoint.rawBytes.Length > 0);
            test(opaqueEndpoint.rawEncoding.Equals(new Ice.EncodingVersion(1, 8)));
        }
        WriteLine("ok");

        Ice.ObjectAdapter adapter;
        Write("test object adapter endpoint information... ");
        Flush();
        {
            string host = communicator.getProperties().getPropertyAsInt("Ice.IPv6") != 0 ? "::1" : "127.0.0.1";
            communicator.getProperties().setProperty("TestAdapter.Endpoints", "tcp -h \"" + host +
                                                     "\" -t 15000:udp -h \"" + host + "\"");
            adapter = communicator.createObjectAdapter("TestAdapter");

            Ice.Endpoint[] endpoints = adapter.getEndpoints();
            test(endpoints.Length == 2);
            Ice.Endpoint[] publishedEndpoints = adapter.getPublishedEndpoints();
            test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));

            Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo());
            test(tcpEndpoint.type() == Ice.TCPEndpointType.value || tcpEndpoint.type() == Ice.SSLEndpointType.value ||
                 tcpEndpoint.type() == Ice.WSEndpointType.value || tcpEndpoint.type() == Ice.WSSEndpointType.value);

            test(tcpEndpoint.host.Equals(host));
            test(tcpEndpoint.port > 0);
            test(tcpEndpoint.timeout == 15000);

            Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endpoints[1].getInfo();
            test(udpEndpoint.host.Equals(host));
            test(udpEndpoint.datagram());
            test(udpEndpoint.port > 0);

            endpoints = new Ice.Endpoint[] { endpoints[0] };
            test(endpoints.Length == 1);
            adapter.setPublishedEndpoints(endpoints);
            publishedEndpoints = adapter.getPublishedEndpoints();
            test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));

            adapter.destroy();

            int port = app.getTestPort(1);
            communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p " + port);
            communicator.getProperties().setProperty("TestAdapter.PublishedEndpoints", app.getTestEndpoint(1));
            adapter = communicator.createObjectAdapter("TestAdapter");

            endpoints = adapter.getEndpoints();
            test(endpoints.Length >= 1);
            publishedEndpoints = adapter.getPublishedEndpoints();
            test(publishedEndpoints.Length == 1);

            foreach (Ice.Endpoint endpoint in endpoints)
            {
                tcpEndpoint = getTCPEndpointInfo(endpoint.getInfo());
                test(tcpEndpoint.port == port);
            }

            tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo());
            test(tcpEndpoint.host.Equals("127.0.0.1"));
            test(tcpEndpoint.port == port);

            adapter.destroy();
        }
        WriteLine("ok");

        int endpointPort = app.getTestPort(0);

        Ice.ObjectPrx @base = communicator.stringToProxy("test:" +
                                                         app.getTestEndpoint(0) + ":" +
                                                         app.getTestEndpoint(0, "udp"));
        TestIntfPrx testIntf = TestIntfPrxHelper.checkedCast(@base);

        string defaultHost = communicator.getProperties().getProperty("Ice.Default.Host");

        Write("test connection endpoint information... ");
        Flush();
        {
            Ice.EndpointInfo    info    = @base.ice_getConnection().getEndpoint().getInfo();
            Ice.TCPEndpointInfo tcpinfo = getTCPEndpointInfo(info);
            test(tcpinfo.port == endpointPort);
            test(!tcpinfo.compress);
            test(tcpinfo.host.Equals(defaultHost));

            Dictionary <string, string> ctx = testIntf.getEndpointInfoAsContext();
            test(ctx["host"].Equals(tcpinfo.host));
            test(ctx["compress"].Equals("false"));
            int port = System.Int32.Parse(ctx["port"]);
            test(port > 0);

            info = @base.ice_datagram().ice_getConnection().getEndpoint().getInfo();
            Ice.UDPEndpointInfo udp = (Ice.UDPEndpointInfo)info;
            test(udp.port == endpointPort);
            test(udp.host.Equals(defaultHost));
        }
        WriteLine("ok");

        Write("testing connection information... ");
        Flush();
        {
            Ice.Connection connection = @base.ice_getConnection();
            connection.setBufferSize(1024, 2048);

            Ice.ConnectionInfo    info   = connection.getInfo();
            Ice.TCPConnectionInfo ipInfo = getTCPConnectionInfo(info);
            test(!info.incoming);
            test(info.adapterName.Length == 0);
            test(ipInfo.remotePort == endpointPort);
            test(ipInfo.localPort > 0);
            if (defaultHost.Equals("127.0.0.1"))
            {
                test(ipInfo.localAddress.Equals(defaultHost));
                test(ipInfo.remoteAddress.Equals(defaultHost));
            }
            test(ipInfo.rcvSize >= 1024);
            test(ipInfo.sndSize >= 2048);

            Dictionary <string, string> ctx = testIntf.getConnectionInfoAsContext();
            test(ctx["incoming"].Equals("true"));
            test(ctx["adapterName"].Equals("TestAdapter"));
            test(ctx["remoteAddress"].Equals(ipInfo.localAddress));
            test(ctx["localAddress"].Equals(ipInfo.remoteAddress));
            test(ctx["remotePort"].Equals(ipInfo.localPort.ToString()));
            test(ctx["localPort"].Equals(ipInfo.remotePort.ToString()));

            if (@base.ice_getConnection().type().Equals("ws") || @base.ice_getConnection().type().Equals("wss"))
            {
                Dictionary <string, string> headers = ((Ice.WSConnectionInfo)info).headers;
                test(headers["Upgrade"].Equals("websocket"));
                test(headers["Connection"].Equals("Upgrade"));
                test(headers["Sec-WebSocket-Protocol"].Equals("ice.zeroc.com"));
                test(headers["Sec-WebSocket-Accept"] != null);

                test(ctx["ws.Upgrade"].Equals("websocket"));
                test(ctx["ws.Connection"].Equals("Upgrade"));
                test(ctx["ws.Sec-WebSocket-Protocol"].Equals("ice.zeroc.com"));
                test(ctx["ws.Sec-WebSocket-Version"].Equals("13"));
                test(ctx["ws.Sec-WebSocket-Key"] != null);
            }

            connection = @base.ice_datagram().ice_getConnection();
            connection.setBufferSize(2048, 1024);

            Ice.UDPConnectionInfo udpInfo = (Ice.UDPConnectionInfo)connection.getInfo();
            test(!udpInfo.incoming);
            test(udpInfo.adapterName.Length == 0);
            test(udpInfo.localPort > 0);
            test(udpInfo.remotePort == endpointPort);

            if (defaultHost.Equals("127.0.0.1"))
            {
                test(udpInfo.remoteAddress.Equals(defaultHost));
                test(udpInfo.localAddress.Equals(defaultHost));
            }
            test(udpInfo.rcvSize >= 2048);
            test(udpInfo.sndSize >= 1024);
        }
        WriteLine("ok");

        testIntf.shutdown();

        communicator.shutdown();
        communicator.waitForShutdown();
    }
Exemplo n.º 31
0
 getRemoteObserver(Ice.ConnectionInfo ci, Ice.Endpoint ei, int i, int j)
 {
     return(null);
 }