/** * Creates a new instance using the configuration. */ protected SMTPCodecFactory(Charset charset, int dataDeferredSize) { encoder = new TextLineEncoder(charset, LineDelimiter.CRLF); decoder = new SMTPDecoder(charset, dataDeferredSize); }
/** * Base type for a Mud Game Server, will setup and prepare from configs. */ public BaseMudGameServer() { logger.info("Setting Configurations."); // Add exit hook to ensure the server gets unbound shutdownThread = new MudShutdownHook(this); Runtime.getRuntime().addShutdownHook(new Thread(shutdownThread, shutdownThread.getClass().getName())); acceptor = new NioSocketAcceptor(CPU_CORES); logger.info("Using {} CPU's for processing.", CPU_CORES); // utilize different cpus for some tasks acceptor.getFilterChain().addLast("executor", new ExecutorFilter( Executors.newCachedThreadPool())); // Bind slf4j logging to Apache Mina Lib acceptor.getFilterChain().addLast("logger", MudConfig.Logging.getFilter()); // acceptor.getFilterChain().addLast("codec", MudConfig.TextOutput.getNewlineOutput()); // decode falnir.mud.commands sent to server acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter( new TextLineEncoder(), new CommandDecoder() ) ); // Add our Connection Handler to Apache Mina's NIO acceptor.setHandler(new ConnectionHandler()); // Set the maximum buffer falnir.mud.commands.input to take in acceptor.getSessionConfig().setReadBufferSize(2048); // Connection Handler's idle loop timing acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, MudConfig.SERVER_TICK); // Start it up! try { hsqldbServer = new HSQLDBServer(); hsqldbServer.Start(); logger.info("Starting Server on port {}", Integer.toString(MudConfig.PORT)); gameLoop = new GameDriver(this); // Bind NIO Server to Game Loop acceptor.bind(new InetSocketAddress(MudConfig.PORT)); } catch (IOException e) { logger.trace(e.getMessage()); } }
/** * Creates a new instance with the specified {@link Charset}. The encoder uses * a UNIX {@link LineDelimiter} and the decoder uses the AUTO * {@link LineDelimiter}. * * @param charset * The charset to use in the encoding and decoding */ public TextLineCodecFactory(Charset charset) { encoder = new TextLineEncoder(charset, LineDelimiter.UNIX); decoder = new TextLineDecoder(charset, LineDelimiter.AUTO); }
/** * Creates a new instance of TextLineCodecFactory. This constructor provides * more flexibility for the developer. * * @param charset * The charset to use in the encoding and decoding * @param encodingDelimiter * The line delimeter for the encoder * @param decodingDelimiter * The line delimeter for the decoder */ public TextLineCodecFactory(Charset charset, String encodingDelimiter, String decodingDelimiter) { encoder = new TextLineEncoder(charset, encodingDelimiter); decoder = new TextLineDecoder(charset, decodingDelimiter); }
/** * Creates a new instance of TextLineCodecFactory. This constructor provides * more flexibility for the developer. * * @param charset * The charset to use in the encoding and decoding * @param encodingDelimiter * The line delimeter for the encoder * @param decodingDelimiter * The line delimeter for the decoder */ public TextLineCodecFactory(Charset charset, LineDelimiter encodingDelimiter, LineDelimiter decodingDelimiter) { encoder = new TextLineEncoder(charset, encodingDelimiter); decoder = new TextLineDecoder(charset, decodingDelimiter); }