Client.cpp 975 Bytes
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#include <Ice/Ice.h>
#include <Printer.h>
#include <stdexcept>

using namespace std;
using namespace Demo;

int
main(int argc, char* argv[])
{
    try
    {
        Ice::CommunicatorHolder ich(argc, argv);
        auto base = ich->stringToProxy("SimplePrinter1:default -p 10000");
        auto printer = Ice::checkedCast<PrinterPrx>(base);
        if(!printer)
        {
            throw std::runtime_error("Invalid proxy");
        }

        printer->printString("Hello World!");

        auto base2 = ich->stringToProxy("SimplePrinter2:default -p 10000");
        auto printer2 = Ice::checkedCast<PrinterPrx>(base2);
        if(!printer2)
        {
            throw std::runtime_error("Invalid proxy");
        }

        printer2->printString("Hello World!");

        printer->shutdown();

    }
    catch(const std::exception& e)
    {
        cerr << e.what() << endl;
        return 1;
    }
    return 0;
}