Hello.
Thank you for the very swift reply.
I am doing the following:
ServerHandler.java
==============
private IoAcceptor socketAcceptor;
public void establishService() {
this.socketAcceptor = new NioSocketAcceptor();
this.socketAcceptor.getFilterChain().addLast("ProtocolFilter", new
ProtocolCodecFilter(new PacketCodecFactory()));
this.socketAcceptor.setHandler(new DemuxingIoHandler());
this.addInternalMessageHandlers();
}
private void addInternalMessageHandlers(){
((DemuxingIoHandler)
this.socketAcceptor.getHandler()).addReceivedMessageHandler(ConnectionPacket.class,
new ConnectionMessageHandler();
((DemuxingIoHandler)
this.socketAcceptor.getHandler()).addSentMessageHandler(SimpleRequestPacket.class,
new SimpleRequestHandler();
}
ConnectionMessageHandler.java
====
public class ConnectionMessageHandler implements
MessageHandler<ConnectionPacket>{
@Override
public void handleMessage(IoSession session, ConnectionPacket message)
throws Exception{
SimpleRequestPacket request = new SimpleRequestPacket(0xBAAC);
session.write(request);
}
}
SimpleRequestPacket.java
======
public class SimpleRequestPacket{
private int request
public SimpleRequestPacket(int request){
this.request = request;
}
public IoBuffer convertToByteData(){
IoBuffer response = IoBuffer.allocate(4);
response.setInt(this.request);
response.flip();
}
}
SimpleRequestHandler.java
========
public class SimpleRequestHandlerimplements
MessageHandler<SimpleRequestPacket>
@Override
public void handleMessage(IoSession session, SimpleRequestPacket
message) throws Exception
{
session.write(message.convertToByteData());
session.write(response);
}
On 31 March 2014 16:33, Emmanuel Lécharny <[email protected]> wrote:
> Le 3/31/14 5:11 PM, Aidan Diffey a écrit :
> > Hello.
> >
> > I am new to using MINA and I have written an application that uses the
> > DemuxingIoHandler as the handler for an IOAcceptor. I have registed some
> > handlers for message recevied and message sent.
> >
> > One of my registed handlers (implementing MessageHandler) is responsible
> > for writing data back to the IoSession. I am doing this using an
> IoBuffer
> > in the following way:
> >
> > @Override
> > public void handleMessage(IoSession session, SimpleRequestPacket
> > message) throws Exception
> > {
> > IoBuffer response = IoBuffer.allocate(4);
> > response.setInt(0xBBAC);
> > response.flip();
> >
> > session.write(response);
> > }
> >
> >
> > The issue I am having is that I am seeing the following message:
> > "org.apache.mina.core.session.UnknownMessageTypeException: No handler
> found
> > for message type: SimpleBuffer"
> >
> > Is there another out-of-the-box handler I can use for SimpleBuffers?
>
> You most certainly have an issue in the way you registred your handlers.
>
> can you provide the code that does that ?
>
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>