Hi Maarten, On 4/12/07, Maarten Bosteels <[EMAIL PROTECTED]> wrote:
Hi folks,Until now I had only implemented server apps with MINA (IoAcceptor), and no client apps (IoConnector). I started working on a small tutorial about ProtocolDecoder/ProtocolEncoder to complement Mark's Getting Started Guide, and while implementing the client side I was wondering if a ReadFuture would be an interesting feauture. Suppose you have a request-response protocol and you want to implement the client synchronously: connect, send a request and wait until the response comes in. What is currently the best way to go ? With a ReadFuture it could be done like this: Object request = ...; ConnectFuture connectFuture = connector.connect(new InetSocketAddress("localhost",5555)); connectFuture.join(100); if (connectFuture.isConnected()) { IoSession session = connectFuture.getSession(); session.write( request ); ReadFuture readFuture = session.read(); readFuture.join(); if (readFuture.messageRead()) { Object response = readFuture.getResult(); doSomethingWith(response); } session.close().join(); } What do you think ?
It sounds very interesting. Assuming we have ReadFuture, should IoHandler.messageReceived() be notified? Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6
