Hi Emmanuel.
When i receive a command, the it just discard the rest of the buffer
moving it to the end. For simplification i just avoided this code:
if(command != null) {
commandEntered(command);
if(buffer.hasRemaining()) {
buffer.position(buffer.position() + buffer.remaining());
}
break;
}
Anyway, the problem doesn't get there, because the command is null for
this situation. It's always a Key, not a command.
Thank you
Luciano Greiner
(51) 81780200
On Wed, Jun 15, 2011 at 12:22 PM, Emmanuel Lecharny <[email protected]> wrote:
> On 6/15/11 5:14 PM, Luciano Greiner wrote:
>>
>> Hello.
>>
>> I wrote a telnet server application using Apache Mina. The clients are
>> barcode collectors, and the inputs are either a command keys (Ex.: TAB
>> or F4) or a single char like a number or a letter.$
>
> if you don't do a buffer.get(), the buffer will always contain something,
> and will then be read again and again and again.
>
> This part of the code is dubious :
>
> while (buffer.hasRemaining()) {
> log.debug("Bytes remaining to proccess: {}", buffer.remaining());
> Command command = commandParser.parse(buffer);
> if(command != null) {
> commandEntered(command);
> break;
> }
> byte data = buffer.get();
> ...
>
>
> the break; will exit the while loop whitout consuming a byte in the bufffer,
> IMO.
>
> Just check around.
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>