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


TypeScript Ice.initialize方法代碼示例

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


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

示例1: init

    async init()
    {
        const initData = new Ice.InitializationData();
        initData.properties = this._com.ice_getCommunicator().getProperties().clone();
        initData.logger = this._logger;
        initData.properties.setProperty("Ice.ACM.Timeout", "2");
        if(this._clientACMTimeout >= 0)
        {
            initData.properties.setProperty("Ice.ACM.Client.Timeout", String(this._clientACMTimeout));
        }
        if(this._clientACMClose >= 0)
        {
            initData.properties.setProperty("Ice.ACM.Client.Close", String(this._clientACMClose));
        }
        if(this._clientACMHeartbeat >= 0)
        {
            initData.properties.setProperty("Ice.ACM.Client.Heartbeat", String(this._clientACMHeartbeat));
        }
        this._communicator = Ice.initialize(initData);

        this._adapter = await this._com.createObjectAdapter(this._serverACMTimeout,
                                                            this._serverACMClose,
                                                            this._serverACMHeartbeat);
    }
開發者ID:zeroc-ice,項目名稱:ice-debian-packaging,代碼行數:24,代碼來源:Client.ts

示例2: allTests


//.........這裏部分代碼省略.........
        }
        catch(ex)
        {
            test(ex instanceof Ice.LocalException, ex);
        }

        await registry.addObject(communicator.stringToProxy("test3@TestAdapter"));
        try
        {
            await communicator.stringToProxy("test3").ice_ping();
        }
        catch(ex)
        {
            test(false, ex);
        }

        await registry.addObject(communicator.stringToProxy("test4"));
        try
        {
            await communicator.stringToProxy("test4").ice_ping();
            test(false);
        }
        catch(ex)
        {
            test(ex instanceof Ice.NoEndpointException, ex);
        }
        out.writeLine("ok");

        out.write("testing locator cache background updates... ");
        {
            const initData = new Ice.InitializationData();
            initData.properties = communicator.getProperties().clone();
            initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1");
            const ic = Ice.initialize(initData);

            await registry.setAdapterDirectProxy("TestAdapter5", await locator.findAdapterById("TestAdapter"));
            await registry.addObject(communicator.stringToProxy("test3@TestAdapter"));

            count = await locator.getRequestCount();
            await ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
            await ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
            count += 3;
            test(count == await locator.getRequestCount());
            await registry.setAdapterDirectProxy("TestAdapter5", null);
            await registry.addObject(communicator.stringToProxy("test3:default"));
            await ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout.
            await ic.stringToProxy("test3").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout.
            test(count == await locator.getRequestCount());
            await Ice.Promise.delay(1200);

            // The following request should trigger the background
            // updates but still use the cached endpoints and
            // therefore succeed.
            await ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
            await ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.

            try
            {
                while(true)
                {
                    await ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
                    await Ice.Promise.delay(10);
                }
            }
            catch(ex)
            {
開發者ID:zeroc-ice,項目名稱:ice-debian-packaging,代碼行數:67,代碼來源:Client.ts

示例3: run


//.........這裏部分代碼省略.........
        ctx.set("two", "TWO");
        ctx.set("three", "THREE");
        {
            test(prx.ice_getContext().size === 0);
            const r = await prx.opContext();
            test(!Ice.MapUtil.equals(r, ctx));
        }

        {
            const r = await prx.opContext(ctx);
            test(prx.ice_getContext().size === 0);
            test(Ice.MapUtil.equals(r, ctx));
        }

        {
            const p2 = await Test.MyClassPrx.checkedCast(prx.ice_context(ctx));
            test(Ice.MapUtil.equals(p2.ice_getContext(), ctx));
            let r = await p2.opContext();
            test(Ice.MapUtil.equals(r, ctx));
            r = await p2.opContext(ctx);
            test(Ice.MapUtil.equals(r, ctx));
        }
    }

    if(!bidir)
    {
        //
        // Test implicit context propagation
        //
        const initData = new Ice.InitializationData();
        initData.properties = communicator.getProperties().clone();
        initData.properties.setProperty("Ice.ImplicitContext", "Shared");

        const ic = Ice.initialize(initData);

        let ctx = new Ice.Context();
        ctx.set("one", "ONE");
        ctx.set("two", "TWO");
        ctx.set("three", "THREE");

        let p3 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:" + helper.getTestEndpoint()));

        ic.getImplicitContext().setContext(ctx);
        test(Ice.MapUtil.equals(ic.getImplicitContext().getContext(), ctx));
        test(Ice.MapUtil.equals(await p3.opContext(), ctx));

        test(ic.getImplicitContext().containsKey("zero") == false);
        const r = ic.getImplicitContext().put("zero", "ZERO");
        test(r === undefined);
        test(ic.getImplicitContext().get("zero") == "ZERO");

        ctx = ic.getImplicitContext().getContext();
        test(Ice.MapUtil.equals(await p3.opContext(), ctx));

        const prxContext = new Ice.Context();
        prxContext.set("one", "UN");
        prxContext.set("four", "QUATRE");

        const combined = new Ice.Context(prxContext);
        for(const [key, value] of ctx)
        {
            if(!combined.has(key))
            {
                combined.set(key, value);
            }
        }
開發者ID:zeroc-ice,項目名稱:ice-debian-packaging,代碼行數:67,代碼來源:Twoways.ts


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