Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
else
{
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)
else
{
await session.say(message);
}
}
}
let communicator;
let completed = false;
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)
const data = await $.getJSON('config.json');
if('Ice.Default.Router' in data)
{
routerConfig = data['Ice.Default.Router'];
}
else
{
throw new Error('Ice.Default.Router not in config file');
}
//
// Initialize the communicator with the Ice.Default.Router property
// provided by 'config.json'
//
const initData = new Ice.InitializationData();
initData.properties = Ice.createProperties();
initData.properties.setProperty("Ice.Default.Router", routerConfig);
communicator = Ice.initialize(initData);
//
// Get a proxy to the Glacier2 router using checkedCast to ensure
// the Glacier2 server is available.
//
const router = await RouterPrx.checkedCast(communicator.getDefaultRouter());
//
// 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);
// use a non-secure (WS) endpoint.
//
// The web server will act as a reverse proxy for WebSocket connections. This
// facilitates the setup of WSS with self-signed certificates because Firefox
// and Internet Explorer certificate exceptions are only valid for the same
// port and host.
//
const secure = document.location.protocol.indexOf("https") != -1;
const proxy = secure ? "DemoGlacier2/router:wss -p 9090 -h " + hostname + " -r /chatwss" :
"DemoGlacier2/router:ws -p 8080 -h " + hostname + " -r /chatws";
//
// Initialize the communicator with the 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", proxy);
communicator = Ice.initialize(initData);
//
// Get a proxy to the Glacier2 router using checkedCast to ensure
// the Glacier2 server is available.
//
const router = await Glacier2.RouterPrx.checkedCast(communicator.getDefaultRouter());
const username = $("#username").val() as string;
const password = $("#password").val() as string;
const session = await router.createSession(username, password);
await runWithSession(router, Demo.ChatSessionPrx.uncheckedCast(session));
}
catch(ex)
{