On 4/27/06, Samuel Doyle <[EMAIL PROTECTED]> wrote:
>
> I'm a bit unclear on the javadoc description of this
> method. The following is the actual description.
>
> WriteFuture write(Object message)
>
>     Writes the specified message to remote peer. This
> operation is asynchronous;
> IoHandler.messageSent(IoSession, Object) will be
> invoked when the message is actually sent to remote
> peer. You can also ait for the returned WriteFuture if
> you want to wait for the session actually closed.
>
> The last part is where it is a bit unclear to me. Is
> it saying that when you join on the future the session
> is to be closed after that? Or does it mean that the
> actual write operation has fully completed and the
> session remains open?


It's an error in the documentation.  Thanks for the notification!
session.write(...).join() just wait for the message to be written.

In addition, is there a synchronized version of this
> method? I'm just curious what is the best way to
> handle a case where you may have multiple threads that
> want to send packets of data to the same session.
> Basically you have multiple client sessions driving
> messages down the same piple to the server, the data
> can not be mixed. Should I do my own locking in this
> case?


Just add .join() after your write() call.  It never returns null.  Or do we
need a synchronous method?  I didn't add it because .join() is simple
enough.  Perhaps I need to add this idiom to the documentation, too. :)

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to