How to use ice - 10 common examples

To help you get started, we’ve selected a few ice examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeroc-ice / ice-demos / typescript / nodejs / Glacier2 / simpleChat / Client.ts View on Github external
await session.say(message);
            }
        }
    }

    let communicator:Ice.Communicator;
    try
    {
        //
        // Initialize the communicator with Ice.Default.Router property
        // set to the simple chat demo Glacier2 router.
        //
        const initData = new Ice.InitializationData();
        initData.properties = Ice.createProperties();
        initData.properties.setProperty("Ice.Default.Router", "DemoGlacier2/router:tcp -p 4063 -h localhost");
        communicator = Ice.initialize(process.argv, initData);

        const router = await Glacier2.RouterPrx.checkedCast(communicator.getDefaultRouter());
        const session = await createSession(router);
        await runWithSession(router, session);
    }
    catch(ex)
    {
        console.log(ex.toString());
        process.exitCode = 1;
    }
    finally
    {
        if(communicator)
        {
            await communicator.destroy();
        }
github zeroc-ice / ice-demos / typescript / nodejs / Manual / simpleFilesystem / Client.ts View on Github external
else
            {
                const file = Filesystem.FilePrx.uncheckedCast(node);
                const text = await file.read();
                for(const line of text)
                {
                    console.log(`${indent}\t${line}`);
                }
            }
        }
    }

    let communicator:Ice.Communicator;
    try
    {
        communicator = Ice.initialize(process.argv);
        if(process.argv.length > 2)
        {
            throw new Error("too many arguments");
        }

        //
        // Create a proxy for the root directory
        //
        const base = communicator.stringToProxy("RootDir:default -h localhost -p 10000");

        //
        // Down-cast the proxy to a directory proxy
        //
        const rootDir = await Filesystem.DirectoryPrx.checkedCast(base);
        if(!rootDir)
        {
github zeroc-ice / ice-demos / js / Ice / minimal / Client.js View on Github external
(async function()
{
    let communicator;
    try
    {
        communicator = Ice.initialize(process.argv);
        //
        // Down-cast the proxy to the hello object interface and invoke
        // the sayHello method.
        //
        const hello = await Demo.HelloPrx.checkedCast(communicator.stringToProxy("hello:tcp -h localhost -p 10000"));
        await hello.sayHello();
    }
    catch(ex)
    {
        console.log(ex.toString());
        process.exitCode  = 1;
    }
    finally
    {
        if(communicator)
        {
github zeroc-ice / ice-demos / typescript / nodejs / Ice / minimal / Client.ts View on Github external
(async () =>
{
    let communicator:Ice.Communicator;
    try
    {
        communicator = Ice.initialize(process.argv);
        //
        // Down-cast the proxy to the hello object interface and invoke
        // the sayHello method.
        //
        const hello = await Demo.HelloPrx.checkedCast(communicator.stringToProxy("hello:tcp -h localhost -p 10000"));
        await hello.sayHello();
    }
    catch(ex)
    {
        console.log(ex.toString());
        process.exitCode = 1;
    }
    finally
    {
        if(communicator)
        {
github zeroc-ice / ice-demos / js / Ice / bidir / Client.js View on Github external
// **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
//
// **********************************************************************

const Ice = require("ice").Ice;
const Demo = require("./generated/Callback").Demo;

//
// Define a servant class that implements Demo.CallbackReceiver
// interface.
//
class CallbackReceiverI extends Demo.CallbackReceiver
{
    callback(num, current)
    {
        console.log("received callback #" + num);
    }
}

let communicator;
github zeroc-ice / ice-demos / js / Glacier2 / simpleChat / Client.js View on Github external
// **********************************************************************
//
// Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
//
// **********************************************************************

const Ice = require("ice").Ice;
const Glacier2 = require("ice").Glacier2;
const Demo = require("./generated/Chat").Demo;

(async function()
{
    //
    // Servant that implements the ChatCallback interface,
    // the message operation just writes the received data
    // to stdout.
    //
    class ChatCallbackI extends Demo.ChatCallback
    {
        message(data)
        {
            console.log(data);
        }
github zeroc-ice / ice-demos / typescript / browser / Chat / Client.ts View on Github external
const username = $("#username").val() as string;
            const password = $("#password").val() as string;
            const session = await router.createSession(username, password);
            await run(router, ChatSessionPrx.uncheckedCast(session));
        }
        catch(ex)
        {
            console.log(ex.toString());
            //
            // Handle any exceptions that occurred during session creation.
            //
            if(ex instanceof Glacier2.PermissionDeniedException)
            {
                await setState(State.Disconnected, "permission denied:\n" + ex.reason);
            }
            else if(ex instanceof Glacier2.CannotCreateSessionException)
            {
                await setState(State.Disconnected, "cannot create session:\n" + ex.reason);
            }
            else if(ex instanceof Ice.ConnectFailedException)
            {
                await setState(State.Disconnected, "connection to server failed");
            }
            else
            {
                await setState(State.Disconnected, ex.toString());
            }
        }
    }
github zeroc-ice / ice-demos / typescript / nodejs / Glacier2 / simpleChat / Client.ts View on Github external
{
            //
            // Get a proxy to the default router and down-cast it to Glacier2.Router
            // interface to ensure Glacier2 server is available.
            //
            console.log("This demo accepts any user-id / password combination.");
            process.stdout.write("user id: ");
            const id = await getline();
            process.stdout.write("password: ");
            const password = await getline();
            const session = await router.createSession(id, password);
            return Demo.ChatSessionPrx.uncheckedCast(session);
        }
        catch(ex)
        {
            if(ex instanceof Glacier2.PermissionDeniedException)
            {
                console.log("permission denied:\n" + ex.reason);
            }
            else if(ex instanceof Glacier2.CannotCreateSessionException)
            {
                console.log("cannot create session:\n" + ex.reason);
            }
            else
            {
                throw ex;
            }
        }
    }
github zeroc-ice / ice-demos / js / Glacier2 / simpleChat / Client.js View on Github external
{
            //
            // Get a proxy to the default rotuer and down-cast it to Glacier2.Router
            // interface to ensure Glacier2 server is available.
            //
            console.log("This demo accepts any user-id / password combination.");
            process.stdout.write("user id: ");
            const id = await getline();
            process.stdout.write("password: ");
            const password = await getline();
            const session = await router.createSession(id, password);
            return Demo.ChatSessionPrx.uncheckedCast(session);
        }
        catch(ex)
        {
            if(ex instanceof Glacier2.PermissionDeniedException)
            {
                console.log("permission denied:\n" + ex.reason);
            }
            else if(ex instanceof Glacier2.CannotCreateSessionException)
            {
                console.log("cannot create session:\n" + ex.reason);
            }
            else
            {
                throw ex;
            }
        }
    }
github zeroc-ice / ice-demos / typescript / browser / Chat / Client.ts View on Github external
//
            // Create a session with the Glacier2 router.
            //
            const username = $("#username").val() as string;
            const password = $("#password").val() as string;
            const session = await router.createSession(username, password);
            await run(router, ChatSessionPrx.uncheckedCast(session));
        }
        catch(ex)
        {
            console.log(ex.toString());
            //
            // Handle any exceptions that occurred during session creation.
            //
            if(ex instanceof Glacier2.PermissionDeniedException)
            {
                await setState(State.Disconnected, "permission denied:\n" + ex.reason);
            }
            else if(ex instanceof Glacier2.CannotCreateSessionException)
            {
                await setState(State.Disconnected, "cannot create session:\n" + ex.reason);
            }
            else if(ex instanceof Ice.ConnectFailedException)
            {
                await setState(State.Disconnected, "connection to server failed");
            }
            else
            {
                await setState(State.Disconnected, ex.toString());
            }
        }