Magic World game server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
826 B

5 years ago
  1. #include <Ice/Ice.h>
  2. #include <Printer.h>
  3. using namespace std;
  4. using namespace Demo;
  5. class PrinterI : public Printer
  6. {
  7. public:
  8. virtual void printString(string s, const Ice::Current&) override;
  9. };
  10. void
  11. PrinterI::printString(string s, const Ice::Current&)
  12. {
  13. cout << s << endl;
  14. }
  15. int
  16. main(int argc, char* argv[])
  17. {
  18. try
  19. {
  20. Ice::CommunicatorHolder ich(argc, argv);
  21. // Server implementation here ...
  22. auto adapter = ich->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
  23. auto servant = make_shared<PrinterI>();
  24. adapter->add(servant, ich->stringToIdentity("SimplePrinter"));
  25. adapter->activate();
  26. ich->waitForShutdown();
  27. }
  28. catch(const std::exception& e)
  29. {
  30. cerr << e.what() << endl;
  31. return 1;
  32. }
  33. return 0;
  34. }