mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "이희승 (Trustin Lee) <trus...@gmail.com>
Subject Re: Protocol Codec Filter encode not called when sending IoBuffer Mina 2.0
Date Fri, 11 Apr 2008 12:40:47 GMT
That assumption is for users who insert multiple ProtocolCodecFilters
into a filter chain to implement a multi-layered protocol.  :)

HTH,

MikeD wrote:
> That explains it then thanks,
> 
> That seems like a flawed assumption and a bit of extra complication to trap fools like
myself, but I can live with it IoBuffer wrapping was my next step as soon as I found it was
the IoBuffer causing the problem.
> 
> MikeD.
> 
> 
> ----- Original Message ----
> From: ""이희승 (Trustin Lee)" <trustin@gmail.com>
> To: users@mina.apache.org
> Sent: Friday, April 11, 2008 12:00:21 PM
> Subject: Re: Protocol Codec Filter encode not called when sending IoBuffer Mina 2.0
> 
> Hi Mike,
> 
> If you write an IoBuffer, ProtocolCodecFilter assumes it's already
> encoded, and therefore your ProtocolEncoder.encode() is never called.
> You could wrap the IoBuffer with some other type.
> 
> HTH,
> 
> MikeD wrote:
>> Hi all,
>>  
>> I’m new tomina so appologies if this is documented somewhere.
>>  
>> I have aclient and server sending IoBuffer’s back and forth.
>>  
>> And now Iwant to make sure I get one message for each message sent so I implement
the ProtocolCodec Filter from the image Server example. (In the encode I want to make a newIoBuffer
with the length of the message at the start because my messages areall arbitary length, to
allow the decode to do its job)
>>  
>> But encodeis never called, but decode is  (soencode never gets to add the 4 bytes
of length to the start)
>>  
>> I thenchanged the imageServer/imgaeClient to send IoBuffers instead of ImageRequestObjects
and that now never calls encode.
>>  
>> ImageClient.javasendRequest becomes
>>  
>>  
>>     public void sendRequest(ImageRequestimageRequest) {
>>         if (session == null) {
>>             //noinspectionThrowableInstanceNeverThrown
>>             imageListener.onException(newThrowable("not connected"));
>>         } else {
>>             IoBuffer buf=IoBuffer.allocate(12);
>>             buf.putInt(10);
>>             buf.putInt(20);
>>             buf.putInt(30);
>>             buf.flip();
>>             session.write(buf);
>>         }
>>     }
>>  
>>  
>> Am I doingsomething wrong? Why does the type of the message matter for callingencode/decode.
>>  
>>  
>> MikeDiskett.
>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around 
>> http://mail.yahoo.com 
> 

-- 
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/


Mime
View raw message