Hi Tiandike,

Another way of doing it is at https://issues.apache.org/jira/browse/DIRMINA-375. I can't promise that it's better :) Here's what your Client1 would become (hopefully there aren't too many mistakes - I'm typing this directly into the email):

InetSocketAddress socketAddress = new InetSocketAddress("localhost", 8080);
IoServiceConfig config = new SocketConnectorConfig();
DefaultIoFilterChainBuilder filterChainBuilder = new DefaultIoFilterChainBuilder();
filterChainBuilder.addLast("codec",  new ProtocolCodecFilter(
                                   new SumUpProtocolCodecFactory(false)));

config.setFilterChainBuilder(filterChainBuilder);

// The ConnectionFactory creates new synchronous connections with the given address & config.
ConnectionFactory cf = new ConnectionFactoryImpl(socketAddress, config);
// createConnection does the actual connect (blocking only).
NonBlockingConnection connection = cf.createConnection();

try {

           for (int i = 0; i < values.length; i++) {
                AddMessage m = new AddMessage();
                m.setSequence(i);
                m.setValue(values[i]);
                connection.send(m);
Object res=connection.receive(); if(res instanceof ResultMessage){
                    System.out.println("return "+(ResultMessage)res);
                }

           }
finally {
  connection.close();
}

Regards,
Brad.

tiandike wrote:
N http://www.nabble.com/file/p12286978/sumup.rar sumup.rar ow i use callback
and wait notify  to implement the syn call.
I want to know if there are any better solutions.

I modify the sumup example to implent syn call.

the client has three java files :client1.java ClientSessionHandler1.java ClientSupport.java

my CallBack interface is interface CallBack {
                
                void setMessage(Object message);
                
        }

ClientSupport implements CallBack and has  connect  , send and quit
functions

the send function return the result from server.

the client1 can use ClientSupport's send function to syn request and get
response from server.








Reply via email to