Esempio n. 1
0
    public IceClientTransportSink (string url)
    {
      IceChannelUtils.ParseIceURL (url, out _host, out _port, out _objectUri);

      Ice.TcpEndpoint te = new Ice.TcpEndpoint (_host, _port);
      _e = Ice.Manager.GetManager().GetEndpoint (te);
    }
Esempio n. 2
0
 getConnectionObserver(Ice.ConnectionInfo ci,
                       Ice.Endpoint ei,
                       Ice.Instrumentation.ConnectionState s,
                       Ice.Instrumentation.ConnectionObserver o)
 {
     return(null);
 }
Esempio n. 3
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.ice_getEndpoints()[0].getInfo();
                if (info.mcastInterface.Length > 0)
                {
                    foreach (var q in lookupReply.ice_getEndpoints())
                    {
                        var r = q.getInfo();
                        if (r is Ice.IPEndpointInfo && ((Ice.IPEndpointInfo)r).host.Equals(info.mcastInterface))
                        {
                            single[0]     = q;
                            _lookups[key] = (LookupReplyPrx)lookupReply.ice_endpoints(single);
                        }
                    }
                }

                if (_lookups[key] == null)
                {
                    // Fallback: just use the given lookup reply proxy if no matching endpoint found.
                    _lookups[key] = lookupReply;
                }
            }
        }
Esempio n. 4
0
        LocatorI(string name, LookupPrx lookup, Ice.Properties properties, string instanceName,
                 Ice.LocatorPrx voidLocator)
        {
            _lookup            = lookup;
            _timeout           = properties.getPropertyAsIntWithDefault(name + ".Timeout", 300);
            _retryCount        = properties.getPropertyAsIntWithDefault(name + ".RetryCount", 3);
            _retryDelay        = properties.getPropertyAsIntWithDefault(name + ".RetryDelay", 2000);
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();
            _traceLevel        = properties.getPropertyAsInt(name + ".Trace.Lookup");
            _instanceName      = instanceName;
            _warned            = false;
            _locator           = lookup.ice_getCommunicator().getDefaultLocator();
            _voidLocator       = voidLocator;
            _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.ice_getEndpoints())
            {
                single[0] = endpt;
                _lookups[(LookupPrx)lookup.ice_endpoints(single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Esempio n. 5
0
 public ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state)
     : base(_attributes)
 {
     _connectionInfo = con;
     _endpoint       = endpt;
     _state          = state;
 }
Esempio n. 6
0
        public IceClientTransportSink(string url)
        {
            IceChannelUtils.ParseIceURL(url, out _host, out _port, out _objectUri);

            Ice.TcpEndpoint te = new Ice.TcpEndpoint(_host, _port);
            _e = Ice.Manager.GetManager().GetEndpoint(te);
        }
Esempio n. 7
0
        public virtual void WriteProxy(object o, Type ot)
        {
            if (!RemotingServices.IsTransparentProxy(o))
            {
                Console.WriteLine("o {0} ot {1} is not transparent proxy!", o, ot);
                throw new InvalidOperationException("object which is not a transparent proxy passed to WriteProxy, type " + ot);
            }

            ObjRef or = RemotingServices.GetObjRefForProxy((System.MarshalByRefObject)o);

            Ice.Identity proxy_ident = new Ice.Identity(or.URI.StartsWith("/") ? or.URI.Substring(1) : or.URI);
            Ice.Endpoint proxy_ep    = null;

            foreach (object cdo in or.ChannelInfo.ChannelData)
            {
                ChannelDataStore cd = cdo as ChannelDataStore;
                if (cd == null)
                {
                    continue;
                }
                foreach (string ch_uri in cd.ChannelUris)
                {
                    string host;
                    int    port;
                    string uri;

                    if (IceChannelUtils.ParseIceURL(ch_uri, out host, out port, out uri))
                    {
                        proxy_ep          = new Ice.TcpEndpoint(host, port);
                        proxy_ep.Incoming = true;
                        break;
                    }
                }
            }

            if (proxy_ep == null)
            {
                throw new InvalidOperationException("Couldn't find valid Ice endpoint/channel for " + o);
            }

            Ice.ProxyData pd = new Ice.ProxyData();
            pd.id     = proxy_ident;
            pd.facet  = new string[0];
            pd.mode   = ProxyMode.Twoway; // FIXME -- do I need to send multiple proxy things here?
            pd.secure = false;

            WriteStruct(pd);
            WriteSize(1);       // one endpoint follows

            // tcp endpoint encapsulation
            WriteObject((short)1); // it's a TCP endpoint
            BeginEncapsulation();
            Ice.TcpEndpoint te = proxy_ep as Ice.TcpEndpoint;
            Write(te.host);
            WriteObject(te.port);
            WriteObject(te.timeout);
            WriteObject(te.compress);
            EndEncapsulation();
        }
Esempio n. 8
0
 public RemoteInvocationHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, int requestId, int size) :
     base(_attributes)
 {
     _connectionInfo = con;
     _endpoint       = endpt;
     _requestId      = requestId;
     _size           = size;
 }
Esempio n. 9
0
 public override bool Equivalent(Ice.Endpoint endpoint)
 {
     if (endpoint is Endpoint sslEndpoint)
     {
         return(_delegate.Equivalent(sslEndpoint._delegate));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 10
0
 public void attachRemoteObserver(Ice.ConnectionInfo info, Ice.Endpoint endpt, int size)
 {
     if (_observer != null)
     {
         _remoteObserver = _observer.getRemoteObserver(info, endpt, 0, size);
         if (_remoteObserver != null)
         {
             _remoteObserver.attach();
         }
     }
 }
Esempio n. 11
0
 public void attachRemoteObserver(Ice.ConnectionInfo info, Ice.Endpoint endpt, int requestId, int sz)
 {
     if (_observer != null)
     {
         _remoteObserver = _observer.getRemoteObserver(info, endpt, requestId, sz);
         if (_remoteObserver != null)
         {
             _remoteObserver.attach();
         }
     }
 }
Esempio n. 12
0
 private static IPEndpoint?getIPEndpoint(Ice.Endpoint endpoint)
 {
     for (Endpoint?e = endpoint; e != null; e = e.Underlying)
     {
         if (e is IPEndpoint)
         {
             return((IPEndpoint)e);
         }
     }
     return(null);
 }
Esempio n. 13
0
 public void attachRemoteObserver(Ice.ConnectionInfo info, Ice.Endpoint endpt, int requestId)
 {
     if (observer_ != null)
     {
         int size = os_.size() - Protocol.headerSize - 4;
         childObserver_ = getObserver().getRemoteObserver(info, endpt, requestId, size);
         if (childObserver_ != null)
         {
             childObserver_.attach();
         }
     }
 }
Esempio n. 14
0
        LocatorI(string name, LookupPrx lookup, Ice.Properties properties, string instanceName,
                 Ice.LocatorPrx voidLocator)
        {
            _timeout           = properties.getPropertyAsIntWithDefault(name + ".Timeout", 300);
            _retryCount        = properties.getPropertyAsIntWithDefault(name + ".RetryCount", 3);
            _retryDelay        = properties.getPropertyAsIntWithDefault(name + ".RetryDelay", 2000);
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();
            _instanceName      = instanceName;
            _warned            = false;
            _locator           = lookup.ice_getCommunicator().getDefaultLocator();
            _voidLocator       = voidLocator;
            _pendingRetryCount = 0;

            try
            {
                lookup.ice_getConnection();
            }
            catch (Ice.LocalException ex)
            {
                StringBuilder b = new StringBuilder();
                b.Append("IceLocatorDiscovery is unable to establish a multicast connection:\n");
                b.Append("proxy = ");
                b.Append(lookup.ToString());
                b.Append('\n');
                b.Append(ex.ToString());
                throw new Ice.PluginInitializationException(b.ToString());
            }

            //
            // 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.ice_getEndpoints())
            {
                try
                {
                    single[0] = endpt;
                    LookupPrx l = (LookupPrx)lookup.ice_endpoints(single);
                    l.ice_getConnection();
                    _lookup[(LookupPrx)lookup.ice_endpoints(single)] = null;
                }
                catch (Ice.LocalException)
                {
                    // Ignore
                }
            }
            Debug.Assert(_lookup.Count > 0);
        }
Esempio n. 15
0
 public Ice.Endpoint GetEndpoint(Ice.Endpoint e)
 {
     lock (_endpointMap) {
         if (_endpointMap.Contains(e))
         {
             Ice.Endpoint ret = (Ice.Endpoint)_endpointMap[e];
             Trace.WriteLine("GetEndpoint: NEW " + e);
             return(ret);
         }
         else
         {
             _endpointMap[e] = e;
             Trace.WriteLine("GetEndpoint: OLD " + e);
             return(e);
         }
     }
 }
Esempio n. 16
0
        public LookupI(LocatorRegistryI registry, LookupPrx lookup, Ice.Properties properties)
        {
            _registry          = registry;
            _timeout           = properties.getPropertyAsIntWithDefault("IceDiscovery.Timeout", 300);
            _retryCount        = properties.getPropertyAsIntWithDefault("IceDiscovery.RetryCount", 3);
            _latencyMultiplier = properties.getPropertyAsIntWithDefault("IceDiscovery.LatencyMultiplier", 1);
            _domainId          = properties.getProperty("IceDiscovery.DomainId");
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer();

            try
            {
                lookup.ice_getConnection();
            }
            catch (Ice.LocalException ex)
            {
                StringBuilder b = new StringBuilder();
                b.Append("IceDiscovery is unable to establish a multicast connection:\n");
                b.Append("proxy = ");
                b.Append(lookup.ToString());
                b.Append('\n');
                b.Append(ex.ToString());
                throw new Ice.PluginInitializationException(b.ToString());
            }

            //
            // 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.ice_getEndpoints())
            {
                try
                {
                    single[0] = endpt;
                    LookupPrx l = (LookupPrx)lookup.ice_endpoints(single);
                    l.ice_getConnection();
                    _lookup[(LookupPrx)lookup.ice_endpoints(single)] = null;
                }
                catch (Ice.LocalException)
                {
                    // Ignore
                }
            }
            Debug.Assert(_lookup.Count > 0);
        }
Esempio n. 17
0
    public ReceiverDispatcher (Ice.Endpoint e, MessageRequestDelegate mrd)
    {
      _e = e;
      _r = e.ProtocolReader;
      _requestHandler = mrd;
      _valid = true;

      // if the endpoint is connected and this endpoint isn't incoming,
      // then we need to wait for the validate message before
      // sending any requests
      if (_e.HasConnection && !_e.Incoming)
        _valid = false;

      _outstandingRequests = new Hashtable();
      _notifiedRequests = new Hashtable();

      _readerThread = new Thread(new ThreadStart (Reader));
      _readerThread.IsBackground = true;
      _readerThread.Start();
    }
Esempio n. 18
0
 public Ice.Instrumentation.Observer getConnectionEstablishmentObserver(Ice.Endpoint endpt, string connector)
 {
     if (_connects.isEnabled())
     {
         try
         {
             Ice.Instrumentation.Observer del = null;
             if (_delegate != null)
             {
                 del = _delegate.getConnectionEstablishmentObserver(endpt, connector);
             }
             return(_connects.getObserver(new EndpointHelper(endpt, connector), del));
         }
         catch (Exception ex)
         {
             _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex);
         }
     }
     return(null);
 }
Esempio n. 19
0
        internal void InternalProcessMessage(Ice.Endpoint replyEp, Stream msgStream, Ice.MessageType mtype)
        {
            // at this point, the ice header has been read, but nothing higher.
            // we don't know very much about this message; we pass it up
            // to (presumably) the formatter for further evaluation

            TransportHeaders headers = new TransportHeaders();

            headers ["__iceMessageType"] = mtype;
            headers ["__iceEndpoint"]    = replyEp;

            IMessage          respMessage;
            ITransportHeaders respHeaders;
            Stream            respStream;

            ServerProcessing res = _next.ProcessMessage(null, null, headers, msgStream,
                                                        out respMessage, out respHeaders,
                                                        out respStream);

            switch (res)
            {
            case ServerProcessing.Complete:
                if (!(respHeaders != null &&
                      respHeaders["__iceNoReply"] != null &&
                      ((bool)respHeaders["__iceNoReply"])))
                {
                    lock (replyEp.Stream) {
                        MemoryStream ms = respStream as MemoryStream;
                        ms.WriteTo(replyEp.Stream);
                    }
                }
                break;

            case ServerProcessing.Async:
                throw new NotImplementedException();

            case ServerProcessing.OneWay:
                // do nothing
                break;
            }
        }
Esempio n. 20
0
        public ReceiverDispatcher(Ice.Endpoint e, MessageRequestDelegate mrd)
        {
            _e = e;
            _r = e.ProtocolReader;
            _requestHandler = mrd;
            _valid          = true;

            // if the endpoint is connected and this endpoint isn't incoming,
            // then we need to wait for the validate message before
            // sending any requests
            if (_e.HasConnection && !_e.Incoming)
            {
                _valid = false;
            }

            _outstandingRequests = new Hashtable();
            _notifiedRequests    = new Hashtable();

            _readerThread = new Thread(new ThreadStart(Reader));
            _readerThread.IsBackground = true;
            _readerThread.Start();
        }
Esempio n. 21
0
        private void ListenerThread()
        {
            if (_e is Ice.TcpEndpoint)
            {
                // loop and accept socket connections, then convert them
                // into Endpoints, and instantiate a ReceiverDispatcher for
                // them.
                while (true)
                {
                    Socket clientSocket = _listener.AcceptSocket();

                    Ice.Endpoint    ne    = (Ice.Endpoint)_e.Clone();
                    Ice.TcpEndpoint tcpep = ne as Ice.TcpEndpoint;

                    if (tcpep == null)
                    {
                        throw new NotSupportedException("Only TCP endpoints are supported");
                    }

                    tcpep.Socket = clientSocket;

                    if (tcpep.HasConnection)
                    {
                        // validate the connection
                        MemoryStream       ms = new MemoryStream();
                        Ice.ProtocolWriter pw = new Ice.ProtocolWriter(ms);
                        pw.BeginMessage(MessageType.ValidateConnection);
                        pw.EndMessage();
                        ms.WriteTo(tcpep.Stream);
                    }

                    tcpep.ReceiverDispatcher = new Ice.ReceiverDispatcher(tcpep, new MessageRequestDelegate(MessageRequestHandler));
                }
            }
            else
            {
                throw new NotImplementedException("ListenerThread managed to get a non-Tcp Ice.Endpoint");
            }
        }
Esempio n. 22
0
        public LookupI(LocatorRegistryI registry, LookupPrx lookup, Ice.Properties properties)
        {
            _registry          = registry;
            _lookup            = lookup;
            _timeout           = properties.getPropertyAsIntWithDefault("IceDiscovery.Timeout", 300);
            _retryCount        = properties.getPropertyAsIntWithDefault("IceDiscovery.RetryCount", 3);
            _latencyMultiplier = properties.getPropertyAsIntWithDefault("IceDiscovery.LatencyMultiplier", 1);
            _domainId          = properties.getProperty("IceDiscovery.DomainId");
            _timer             = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).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.ice_getEndpoints())
            {
                single[0] = endpt;
                _lookups[(LookupPrx)lookup.ice_endpoints(single)] = null;
            }
            Debug.Assert(_lookups.Count > 0);
        }
Esempio n. 23
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 (Exception ex)
         {
             _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex);
         }
     }
     return(null);
 }
Esempio n. 24
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));
 }
Esempio n. 25
0
 public EndpointHelper(Ice.Endpoint endpt) : base(_attributes)
 {
     _endpoint = endpt;
 }
Esempio n. 26
0
 public EndpointHelper(Ice.Endpoint endpt, string id) : base(_attributes)
 {
     _endpoint = endpt;
     _id       = id;
 }
Esempio n. 27
0
 getConnectionEstablishmentObserver(Ice.Endpoint e, string s)
 {
     return(null);
 }
Esempio n. 28
0
 getEndpointLookupObserver(Ice.Endpoint e)
 {
     return(null);
 }
Esempio n. 29
0
 public IceServerChannel(Ice.Endpoint ep,
                         IServerChannelSinkProvider serverSinkProvider)
 {
     _e = Ice.Manager.GetManager().GetEndpoint(ep);
     Init(serverSinkProvider);
 }
Esempio n. 30
0
 public IceServerChannel(Ice.Endpoint ep)
 {
     _e = Ice.Manager.GetManager().GetEndpoint(ep);
     Init(null);
 }
Esempio n. 31
0
 private void MessageRequestHandler(Ice.Endpoint e,
                                    Stream msgStream,
                                    Ice.MessageType mtype)
 {
     _sink.InternalProcessMessage(e, msgStream, mtype);
 }
Esempio n. 32
0
 public IceServerChannel (Ice.Endpoint ep,
                          IServerChannelSinkProvider serverSinkProvider)
 {
   _e = Ice.Manager.GetManager().GetEndpoint (ep);
   Init (serverSinkProvider);
 }
Esempio n. 33
0
            public static void allTests(global::Test.TestHelper helper)
            {
                Ice.Communicator communicator = helper.communicator();
                var output = helper.getWriter();

                output.Write("testing proxy endpoint information... ");
                output.Flush();
                {
                    var p1 = IObjectPrx.Parse(
                        "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", communicator);

                    Ice.Endpoint[] endps = p1.Endpoints;

                    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)));
                }
                output.WriteLine("ok");

                Ice.ObjectAdapter adapter;
                output.Write("test object adapter endpoint information... ");
                output.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 = helper.getTestPort(1);
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p " + port);
                    communicator.getProperties().setProperty("TestAdapter.PublishedEndpoints", helper.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();
                }
                output.WriteLine("ok");

                int endpointPort = helper.getTestPort(0);

                var @base = IObjectPrx.Parse("test:" +
                                             helper.getTestEndpoint(0) + ":" +
                                             helper.getTestEndpoint(0, "udp"), communicator);
                var testIntf = Test.TestIntfPrx.CheckedCast(@base);

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

                output.Write("test connection endpoint information... ");
                output.Flush();
                {
                    Ice.EndpointInfo    info    = @base.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 = int.Parse(ctx["port"]);
                    test(port > 0);

                    info = @base.Clone(invocationMode: InvocationMode.Datagram).GetConnection().getEndpoint().getInfo();
                    Ice.UDPEndpointInfo udp = (Ice.UDPEndpointInfo)info;
                    test(udp.port == endpointPort);
                    test(udp.host.Equals(defaultHost));
                }
                output.WriteLine("ok");

                output.Write("testing connection information... ");
                output.Flush();
                {
                    Ice.Connection connection = @base.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.GetConnection().type().Equals("ws") || @base.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.Clone(invocationMode: InvocationMode.Datagram).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);
                }
                output.WriteLine("ok");

                testIntf.shutdown();

                communicator.shutdown();
                communicator.waitForShutdown();
            }
Esempio n. 34
0
 public IceServerChannel (Ice.Endpoint ep) {
   _e = Ice.Manager.GetManager().GetEndpoint (ep);
   Init (null);
 }