当前位置: 首页>>代码示例>>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;未经允许,请勿转载。