Search in sources :

Example 1 with MTGConsoleHandler

use of org.magic.console.MTGConsoleHandler in project MtgDesktopCompanion by nicho92.

the class ConsoleServer method start.

@Override
public void start() throws IOException {
    acceptor = new NioSocketAcceptor();
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName(getString("ENCODING")))));
    acceptor.getSessionConfig().setReadBufferSize(Integer.parseInt(getString("BUFFER-SIZE")));
    acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, Integer.parseInt(getString("IDLE-TIME")));
    acceptor.setHandler(new MTGConsoleHandler());
    acceptor.bind(new InetSocketAddress(Integer.parseInt(getString("SERVER-PORT"))));
    logger.info("Server started on port " + getString("SERVER-PORT"));
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ProtocolCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter) NioSocketAcceptor(org.apache.mina.transport.socket.nio.NioSocketAcceptor) TextLineCodecFactory(org.apache.mina.filter.codec.textline.TextLineCodecFactory) MTGConsoleHandler(org.magic.console.MTGConsoleHandler)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 ProtocolCodecFilter (org.apache.mina.filter.codec.ProtocolCodecFilter)1 TextLineCodecFactory (org.apache.mina.filter.codec.textline.TextLineCodecFactory)1 NioSocketAcceptor (org.apache.mina.transport.socket.nio.NioSocketAcceptor)1 MTGConsoleHandler (org.magic.console.MTGConsoleHandler)1