1 20 package org.apache.mina.example.sumup.codec; 21 22 import org.apache.mina.common.ByteBuffer; 23 import org.apache.mina.common.IoSession; 24 import org.apache.mina.example.sumup.message.AbstractMessage; 25 import org.apache.mina.example.sumup.message.AddMessage; 26 import org.apache.mina.filter.codec.ProtocolDecoderOutput; 27 import org.apache.mina.filter.codec.demux.MessageDecoder; 28 29 35 public class AddMessageDecoder extends AbstractMessageDecoder { 36 37 public AddMessageDecoder() { 38 super(Constants.ADD); 39 } 40 41 protected AbstractMessage decodeBody(IoSession session, ByteBuffer in) { 42 if (in.remaining() < Constants.ADD_BODY_LEN) { 43 return null; 44 } 45 46 AddMessage m = new AddMessage(); 47 m.setValue(in.getInt()); 48 return m; 49 } 50 51 public void finishDecode(IoSession session, ProtocolDecoderOutput out) 52 throws Exception { 53 } 54 } 55 | Popular Tags |