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
)
35 "t: send greeting as twoway\n" +
36 "o: send greeting as oneway\n" +
37 "O: send greeting as batch oneway\n" +
38 "d: send greeting as datagram\n" +
39 "D: send greeting as batch datagram\n" +
40 "f: flush all batch requests\n" +
50 System
.err
.println(appName() + ": too many arguments");
55 // Since this is an interactive demo we want to clear the
56 // Application installed interrupt callback and install our
59 setInterruptHook(new ShutdownHook());
61 HelloPrx twoway
= HelloPrxHelper
.checkedCast(
62 communicator().propertyToProxy("Hello.Proxy").ice_twoway().ice_timeout(-1).ice_secure(false));
65 System
.err
.println("invalid object reference");
68 HelloPrx oneway
= HelloPrxHelper
.uncheckedCast(twoway
.ice_oneway());
69 HelloPrx batchOneway
= HelloPrxHelper
.uncheckedCast(twoway
.ice_batchOneway());
70 HelloPrx datagram
= HelloPrxHelper
.uncheckedCast(twoway
.ice_datagram());
71 HelloPrx batchDatagram
= HelloPrxHelper
.uncheckedCast(twoway
.ice_batchDatagram());
75 java
.io
.BufferedReader in
= new java
.io
.BufferedReader(new java
.io
.InputStreamReader(System
.in
));
82 System
.out
.print("==> ");
93 else if(line
.equals("o"))
97 else if(line
.equals("O"))
99 batchOneway
.sayHello();
101 else if(line
.equals("d"))
105 else if(line
.equals("D"))
107 batchDatagram
.sayHello();
109 else if(line
.equals("f"))
111 communicator().flushBatchRequests();
113 else if(line
.equals("x"))
117 else if(line
.equals("?"))
123 System
.out
.println("unknown command `" + line
+ "'");
127 catch(java
.io
.IOException ex
)
129 ex
.printStackTrace();
131 catch(Ice
.LocalException ex
)
133 ex
.printStackTrace();
136 while(!line
.equals("x"));
144 Client app
= new Client();
145 int status
= app
.main("Client", args
, "config.client");