예제 #1
0
        private void destroyServiceCommunicator(string service, Ice.Communicator communicator)
        {
            if (communicator != null)
            {
                try
                {
                    communicator.shutdown();
                    communicator.waitForShutdown();
                }
                catch (Ice.CommunicatorDestroyedException)
                {
                    //
                    // Ignore, the service might have already destroyed
                    // the communicator for its own reasons.
                    //
                }
                catch (Exception e)
                {
                    _logger.warning("ServiceManager: exception while shutting down communicator for service "
                                    + service + "\n" + e.ToString());
                }

                removeAdminFacets("IceBox.Service." + service + ".");
                communicator.destroy();
            }
        }
예제 #2
0
 ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
 {
     Ice.Communicator communicator = current.adapter.getCommunicator();
     Ice.InputStream  inS          = new Ice.InputStream(communicator, inParams);
     inS.startEncapsulation();
     Ice.OutputStream outS = new Ice.OutputStream(communicator);
     outS.startEncapsulation();
     if (current.operation.Equals("opOneway"))
     {
         outParams = new byte[0];
         return(true);
     }
     else if (current.operation.Equals("opString"))
     {
         string s = inS.readString();
         outS.writeString(s);
         outS.writeString(s);
         outS.endEncapsulation();
         outParams = outS.finished();
         return(true);
     }
     else if (current.operation.Equals("opException"))
     {
         Test.MyException ex = new Test.MyException();
         outS.writeException(ex);
         outS.endEncapsulation();
         outParams = outS.finished();
         return(false);
     }
     else if (current.operation.Equals("shutdown"))
     {
         communicator.shutdown();
         outParams = null;
         return(true);
     }
     else if (current.operation.Equals("ice_isA"))
     {
         string s = inS.readString();
         if (s.Equals("::Test::MyClass"))
         {
             outS.writeBool(true);
         }
         else
         {
             outS.writeBool(false);
         }
         outS.endEncapsulation();
         outParams = outS.finished();
         return(true);
     }
     else
     {
         Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
         ex.id        = current.id;
         ex.facet     = current.facet;
         ex.operation = current.operation;
         throw ex;
     }
 }
예제 #3
0
 /// <summary>
 /// 释放
 /// </summary>
 public void Dispose()
 {
     isDis  = true;
     client = null;
     ic.shutdown();
     ic.Dispose();
     ic = null;
 }
예제 #4
0
 ice_invoke_async(Ice.AMD_Object_ice_invoke cb, byte[] inParams, Ice.Current current)
 {
     Ice.Communicator communicator = current.adapter.getCommunicator();
     Ice.InputStream  inS          = Ice.Util.createInputStream(communicator, inParams);
     inS.startEncapsulation();
     Ice.OutputStream outS = Ice.Util.createOutputStream(communicator);
     outS.startEncapsulation();
     if (current.operation.Equals("opOneway"))
     {
         cb.ice_response(true, new byte[0]);
     }
     else if (current.operation.Equals("opString"))
     {
         string s = inS.readString();
         outS.writeString(s);
         outS.writeString(s);
         outS.endEncapsulation();
         cb.ice_response(true, outS.finished());
     }
     else if (current.operation.Equals("opException"))
     {
         Test.MyException ex = new Test.MyException();
         outS.writeException(ex);
         outS.endEncapsulation();
         cb.ice_response(false, outS.finished());
     }
     else if (current.operation.Equals("shutdown"))
     {
         communicator.shutdown();
         cb.ice_response(true, null);
     }
     else if (current.operation.Equals("ice_isA"))
     {
         string s = inS.readString();
         if (s.Equals("::Test::MyClass"))
         {
             outS.writeBool(true);
         }
         else
         {
             outS.writeBool(false);
         }
         outS.endEncapsulation();
         cb.ice_response(true, outS.finished());
     }
     else
     {
         Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
         ex.id        = current.id;
         ex.facet     = current.facet;
         ex.operation = current.operation;
         throw ex;
     }
 }
예제 #5
0
 /// <summary>
 /// Destroy the communicator. Does nothing if the communicator was not created.
 /// </summary>
 private void DestroyCommunicator()
 {
     if (communicator != null)
     {
         try
         {
             communicator.shutdown();
         }
         catch (System.Exception) { }
         finally
         {
             communicator = null;
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Destroy the communicator. Does nothing if the communicator was not created.
        /// </summary>
        private void DestroyCommunicator()
        {
            if (communicator != null)
            {
                try
                {
                    communicator.shutdown();
                }
                catch (System.Exception) { }

                communicator = null;
            }

            Running = false;
        }
예제 #7
0
        public void Dispose()
        {
            try
            {
                if (ic != null)
                {
                    ic.shutdown();
                    ic.Dispose();
                    ic = null;
                }

                client = null;
            }
            catch
            {
            }
        }
예제 #8
0
파일: IceHelper.cs 프로젝트: metoer/wpf
 public void Dispose()
 {
     try
     {
         Client = null;
         if (ic != null)
         {
             ic.shutdown();
             ic.Dispose();
             ic = null;
         }
     }
     catch (Exception e)
     {
         LogHelper.Instance.WirteErrorMsg(e.Message);
     }
 }
예제 #9
0
        public static void Shutdown()
        {
            try
            {
                if (comm != null)
                {
                    comm.shutdown();
                }

                if (adminSessionPrx != null)
                {
                    adminSessionPrx.destroy();
                }

                if (router != null)
                {
                    router.destroySession();
                }
            }
            catch (Exception) { }
        }
예제 #10
0
        public static int Main(string[] args)
        {
            try
            {
                using var communicator = new Ice.Communicator(ref args, new Dictionary <string, string>()
                {
                    { "Ice.Admin.DelayCreation", "1" }
                });

                Console.CancelKeyPress += (sender, eventArgs) =>
                {
                    eventArgs.Cancel = true;
                    communicator.shutdown();
                };

                return(run(communicator, args));
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                return(1);
            }
        }
예제 #11
0
파일: AllTests.cs 프로젝트: motuii/ice
            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();
            }
예제 #12
0
 public void Stop()
 {
     communicator.getLogger().print("Ice shutdown!");
     communicator.shutdown();
 }