I created an XMPP mock server that handles PLAIN encryption slings. I can use Pidgin and go through all session creation to such an extent that Pidgin considers that the user is on the actual XMPP server and sends regular pings.
However, it seems that not all messages are processed correctly, and when I receive a successful login, it was just luck. I say maybe 1/10 times when I really connected. In other cases, it seems that Pidgin missed a message or I dropped messages in order to quickly move around the vehicle.
If I enable the Pidgin XMPP Console plugin, the first connection will ALWAYS succeed, but the second user will not be able to skip it, it usually dies when Pidgin requests Service Discovery.
My Mina code looks something like this:
try
{
int PORT = 20600;
IoAcceptor acceptor = null;
acceptor = new NioSocketAcceptor();
acceptor.getFilterChain().addFirst("codec", new ProtocolCodecFilter( new ProtocolCodecFactoryImpl()));
acceptor.getFilterChain().addLast("executor", new ExecutorFilter(IoEventType.MESSAGE_RECEIVED));
acceptor.setHandler( new SimpleServerHandler());
acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
acceptor.bind( new InetSocketAddress(PORT));
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
It SimpleServerHandleris responsible for processing messages / stanzas and creating a session. The function messageReceivedlooks like this:
@Override
public void messageReceived(IoSession session, Object msg) throws Exception
{
String str = msg.toString();
System.out.println("MESSAGE: " + str);
process(session, str);
}
and finally, the process is responsible for parsing the message and recording the response. I use sychonized on my entry:
public void sessionWrite(IoSession session, String buf)
{
synchronized(session)
{
WriteFuture future = session.write(buf);
}
}
I shortened my processing code for brevity, but it just searches for specific pieces of data, processes the response, and calls sessionWrite(...)
My question is: will this template work? And if not, should I consider moving the received messages to the queue and just processing the queue with a timer?