1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
12 public class Client
extends Ice
.Application
14 class ShutdownHook
extends Thread
21 communicator().destroy();
23 catch(Ice
.LocalException ex
)
30 public class Callback_Hello_sayHelloI
extends Callback_Hello_sayHello
33 public void response()
38 public void exception(Ice
.LocalException ex
)
40 System
.err
.println("sayHello AMI call failed:");
45 public void exception(Ice
.UserException ex
)
47 if(ex
instanceof Demo
.RequestCanceledException
)
49 System
.out
.println("Demo.RequestCanceledException");
63 "i: send immediate greeting\n" +
64 "d: send delayed greeting\n" +
65 "s: shutdown the server\n" +
75 System
.err
.println(appName() + ": too many arguments");
80 // Since this is an interactive demo we want to clear the
81 // Application installed interrupt callback and install our
84 setInterruptHook(new ShutdownHook());
86 HelloPrx hello
= HelloPrxHelper
.checkedCast(communicator().propertyToProxy("Hello.Proxy"));
89 System
.err
.println("invalid proxy");
95 java
.io
.BufferedReader in
= new java
.io
.BufferedReader(new java
.io
.InputStreamReader(System
.in
));
102 System
.out
.print("==> ");
104 line
= in
.readLine();
113 else if(line
.equals("d"))
115 hello
.begin_sayHello(5000, new Callback_Hello_sayHelloI());
117 else if(line
.equals("s"))
121 else if(line
.equals("x"))
127 System
.out
.println("unknown command `" + line
+ "'");
131 catch(java
.io
.IOException ex
)
133 ex
.printStackTrace();
135 catch(Ice
.UserException ex
)
137 ex
.printStackTrace();
139 catch(Ice
.LocalException ex
)
141 ex
.printStackTrace();
144 while(!line
.equals("x"));
152 Client app
= new Client();
153 int status
= app
.main("Client", args
, "config.client");