Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//
// Use ACM heartbeat to keep session alive.
//
const connection = router.ice_getCachedConnection();
if(timeout > 0)
{
connection.setACM(timeout, undefined, Ice.ACMHeartbeat.HeartbeatAlways);
}
connection.setCloseCallback(() => console.log("Connection lost"));
//
// Create the ChatCallback servant and add it to the ObjectAdapter.
//
const callback = Demo.ChatCallbackPrx.uncheckedCast(
adapter.add(new ChatCallbackI(), new Ice.Identity("callback", category)));
//
// Set the chat session callback.
//
await session.setCallback(callback);
//
// The chat function sequantially reads stdin messages
// and send it to server using the session say method.
//
while(true)
{
process.stdout.write("==> ");
const message = await getline();
if(message == "/quit")
//
// Use ACM heartbeat to keep session alive.
//
const connection = router.ice_getCachedConnection();
if(timeout > 0)
{
connection.setACM(timeout, undefined, Ice.ACMHeartbeat.HeartbeatAlways);
}
connection.setCloseCallback(() => console.log("Connection lost"));
//
// Create the ChatCallback servant and add it to the ObjectAdapter.
//
const callback = Demo.ChatCallbackPrx.uncheckedCast(
adapter.add(new ChatCallbackI(), new Ice.Identity("callback", category)));
//
// Set the chat session callback.
//
await session.setCallback(callback);
//
// The chat function sequentially reads stdin messages and
// sends them to the server using the session say method.
//
while(true)
{
process.stdout.write("==> ");
const message = await getline();
if(message == "/quit")
//
// Use ACM heartbeat to keep session alive.
//
const connection = router.ice_getCachedConnection();
if(timeout > 0)
{
connection.setACM(timeout, undefined, Ice.ACMHeartbeat.HeartbeatAlways);
}
//
// Create the ChatCallback servant and add it to the
// ObjectAdapter.
//
const callback = ChatRoomCallbackPrx.uncheckedCast(adapter.add(new ChatCallbackI(),
new Ice.Identity("callback", category)));
//
// Set the chat session callback.
//
await session.setCallback(callback);
await setState(State.Connected);
//
// Process input events in the input textbox until completed.
//
await new Promise(
(resolve, reject) =>
{
$("#input").keypress(
e =>
//
// Use ACM heartbeat to keep session alive.
//
const connection = router.ice_getCachedConnection();
if(timeout > 0)
{
connection.setACM(timeout, undefined, Ice.ACMHeartbeat.HeartbeatAlways);
}
connection.setCloseCallback(() => error("Connection lost"));
//
// Create the ChatCallback servant and add it to the ObjectAdapter.
//
const callback = Demo.ChatCallbackPrx.uncheckedCast(
adapter.add(new ChatCallbackI(), new Ice.Identity("callback", category)));
//
// Set the chat session callback.
//
await session.setCallback(callback);
//
// Stop animating the loading progress bar and transition to the chat screen.
//
stopProgress(true);
await transition("#loading", "#chat-form");
$("#loading .meter").css("width", "0%");
state = State.Connected;
$("#input").focus();