1//
2// Copyright (c) ZeroC, Inc. All rights reserved.
3//
4
5import {Ice} from "ice";
6import {Test} from "./generated";
7import {TestHelper} from "../../../Common/TestHelper";
8import {InitialI} from "./InitialI";
9
10export class Server extends TestHelper
11{
12    async run(args:string[])
13    {
14        let communicator:Ice.Communicator;
15        let echo:Test.EchoPrx;
16        try
17        {
18            [communicator] = this.initialize(args);
19            echo = await Test.EchoPrx.checkedCast(communicator.stringToProxy("__echo:" + this.getTestEndpoint()));
20            const adapter:Ice.ObjectAdapter = await communicator.createObjectAdapter("");
21            const base:Ice.ObjectPrx = communicator.stringToProxy("initial:" + this.getTestEndpoint());
22            adapter.add(new InitialI(adapter, base), Ice.stringToIdentity("initial"));
23            await echo.setConnection();
24            echo.ice_getCachedConnection().setAdapter(adapter);
25            this.serverReady();
26            await communicator.waitForShutdown();
27        }
28        finally
29        {
30            if(echo)
31            {
32                await echo.shutdown();
33            }
34
35            if(communicator)
36            {
37                await communicator.destroy();
38            }
39        }
40    }
41}
42