當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Ice.ArrayUtil.shuffle方法代碼示例

本文整理匯總了TypeScript中ice.Ice.ArrayUtil.shuffle方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Ice.ArrayUtil.shuffle方法的具體用法?TypeScript Ice.ArrayUtil.shuffle怎麽用?TypeScript Ice.ArrayUtil.shuffle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ice.Ice.ArrayUtil的用法示例。


在下文中一共展示了Ice.ArrayUtil.shuffle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: allTests

    async allTests()
    {
        async function createTestIntfPrx(adapters:Test.RemoteObjectAdapterPrx[])
        {
            let endpoints:Ice.Endpoint[] = [];
            let obj = null;
            for(const adapter of adapters)
            {
                obj = await adapter.getTestIntf();
                endpoints = endpoints.concat(obj.ice_getEndpoints());
            }
            return Test.TestIntfPrx.uncheckedCast(obj.ice_endpoints(endpoints));
        }

        async function deactivate(communicator:Test.RemoteCommunicatorPrx,
                                  adapters:Test.RemoteObjectAdapterPrx[])
        {
            for(const adapter of adapters)
            {
                await communicator.deactivateObjectAdapter(adapter);
            }
        }

        const out = this.getWriter();
        let communicator = this.communicator();
        const properties = communicator.getProperties().clone();
        out.write("testing stringToProxy... ");
        const ref = "communicator:" + this.getTestEndpoint();
        let com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref));
        test(com !== null);
        out.writeLine("ok");

        out.write("testing binding with single endpoint... ");
        {
            const adapter = await com.createObjectAdapter("Adapter", "default");

            const test1 = await adapter.getTestIntf();
            const test2 = await adapter.getTestIntf();
            test(await test1.ice_getConnection() === await test2.ice_getConnection());

            await test1.ice_ping();
            await test2.ice_ping();

            await com.deactivateObjectAdapter(adapter);

            const test3 = Test.TestIntfPrx.uncheckedCast(test1);
            test(await test3.ice_getConnection() === await test1.ice_getConnection());
            test(await test3.ice_getConnection() === await test2.ice_getConnection());

            try
            {
                await test3.ice_ping();
                test(false);
            }
            catch(ex)
            {
                test(isConnectionFailed(ex), ex);
            }

        }
        out.writeLine("ok");

        await communicator.destroy();
        [communicator] = this.initialize(properties);
        com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref));

        out.write("testing binding with multiple endpoints... ");
        {
            const adapters = await Promise.all(
                [
                    com.createObjectAdapter("Adapter11", "default"),
                    com.createObjectAdapter("Adapter12", "default"),
                    com.createObjectAdapter("Adapter13", "default")
                ]);

            //
            // Ensure that when a connection is opened it's reused for new
            // proxies and that all endpoints are eventually tried.
            //
            let names = ["Adapter11", "Adapter12", "Adapter13"];
            while(names.length > 0)
            {
                const adpts = Ice.ArrayUtil.clone(adapters);
                const test1 = await createTestIntfPrx(adpts);
                Ice.ArrayUtil.shuffle(adpts);
                const test2 = await createTestIntfPrx(adpts);
                Ice.ArrayUtil.shuffle(adpts);
                const test3 = await createTestIntfPrx(adpts);
                await test1.ice_ping();
                test(await test1.ice_getConnection() == await test2.ice_getConnection());
                test(await test2.ice_getConnection() == await test3.ice_getConnection());

                const name = await test1.getAdapterName();
                const index = names.indexOf(name);
                if(index !== -1)
                {
                    names.splice(index, 1);
                }

                const conn = await test1.ice_getConnection();
//.........這裏部分代碼省略.........
開發者ID:zeroc-ice,項目名稱:ice-debian-packaging,代碼行數:101,代碼來源:Client.ts


注:本文中的ice.Ice.ArrayUtil.shuffle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。