Java Code Examples for org.apache.mina.core.buffer.IoBuffer#setAllocator()
The following examples show how to use
org.apache.mina.core.buffer.IoBuffer#setAllocator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrossServer.java From jforgame with Apache License 2.0 | 6 votes |
/** * start Mina serversocket * @throws Exception */ @Override public void start() throws Exception { final int serverPort = ServerConfig.getInstance().getCrossPort(); IoBuffer.setUseDirectBuffer(false); IoBuffer.setAllocator(new SimpleBufferAllocator()); acceptor = new NioSocketAcceptor(pool); acceptor.setReuseAddress(true); acceptor.getSessionConfig().setAll(getSessionConfig()); logger.info("cross server start at port:{},正在监听服务器点对点的连接...", serverPort); DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain(); filterChain.addLast("codec", new ProtocolCodecFilter(SerializerHelper.getInstance().getCodecFactory())); //指定业务逻辑处理器 acceptor.setHandler(new Game2GameIoHandler(BaseCrossMessageDispatcher.getInstance())); //设置端口号 acceptor.setDefaultLocalAddress(new InetSocketAddress(serverPort)); //启动监听 acceptor.bind(); }
Example 2
Source File: MinaSocketServer.java From jforgame with Apache License 2.0 | 6 votes |
/** * start Mina serversocket * @throws Exception */ @Override public void start() throws Exception { int serverPort = ServerConfig.getInstance().getServerPort(); IoBuffer.setUseDirectBuffer(false); IoBuffer.setAllocator(new SimpleBufferAllocator()); acceptor = new NioSocketAcceptor(pool); acceptor.setReuseAddress(true); acceptor.getSessionConfig().setAll(getSessionConfig()); logger.info("mina socket server start at port:{},正在监听客户端的连接...", serverPort); DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain(); filterChain.addLast("codec", new ProtocolCodecFilter(SerializerHelper.getInstance().getCodecFactory())); filterChain.addLast("moduleEntrance", new ModuleEntranceFilter()); filterChain.addLast("msgTrace", new MessageTraceFilter()); filterChain.addLast("flood", new FloodFilter()); //指定业务逻辑处理器 acceptor.setHandler(new ServerSocketIoHandler(new MessageDispatcher())); //设置端口号 acceptor.setDefaultLocalAddress(new InetSocketAddress(serverPort)); //启动监听 acceptor.bind(); }
Example 3
Source File: CashShopServer.java From mapleLemon with GNU General Public License v2.0 | 6 votes |
public static void run_startup_configurations() { autoPaoDian = Integer.parseInt(ServerProperties.getProperty("autoPaoDian", "1")); port = Short.parseShort(ServerProperties.getProperty("cashshop.port", String.valueOf(DEFAULT_PORT))); ip = ServerProperties.getProperty("world.host", ServerConstants.IP) + ":" + port; IoBuffer.setUseDirectBuffer(false); IoBuffer.setAllocator(new SimpleBufferAllocator()); acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory())); acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 30); players = new PlayerStorage(MapleServerHandler.CASH_SHOP_SERVER); try { acceptor.setHandler(new MapleServerHandler(MapleServerHandler.CASH_SHOP_SERVER)); acceptor.bind(new InetSocketAddress(port)); ((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true); FileoutputUtil.log("完成!"); FileoutputUtil.log("商城伺服器正在监听" + port + "端口\r\n"); } catch (IOException e) { FileoutputUtil.log("失败!"); System.err.println("无法绑定" + port + "端口"); throw new RuntimeException("绑定端口失败.", e); } }
Example 4
Source File: LoginServer.java From mapleLemon with GNU General Public License v2.0 | 5 votes |
public static void run_startup_configurations() { userLimit = ServerProperties.getProperty("userlimit", 140); serverName = ServerProperties.getProperty("serverName", "MapleStory"); flag = ServerProperties.getProperty("flag", (byte) 3); adminOnly = Boolean.parseBoolean(ServerProperties.getProperty("admin", "false")); maxCharacters = ServerProperties.getProperty("maxCharacters", 30); autoReg = Boolean.parseBoolean(ServerProperties.getProperty("autoReg", "false")); checkMacs = Boolean.parseBoolean(ServerProperties.getProperty("checkMacs", "false")); port = Short.parseShort(ServerProperties.getProperty("world.port", String.valueOf(DEFAULT_PORT))); IoBuffer.setUseDirectBuffer(false); IoBuffer.setAllocator(new SimpleBufferAllocator()); acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MapleCodecFactory())); acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 30); try { acceptor.setHandler(new MapleServerHandler(MapleServerHandler.LOGIN_SERVER)); acceptor.bind(new InetSocketAddress(port)); ((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true); FileoutputUtil.log("\"登入\"伺服器正在监听" + port + "端口\r\n"); } catch (IOException e) { System.err.println("无法绑定" + port + "端口: " + e); } }
Example 5
Source File: ConnectionManagerImpl.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void initialize(XMPPServer server) { super.initialize(server); // Check if we need to configure MINA to use Direct or Heap Buffers // Note: It has been reported that heap buffers are 50% faster than direct buffers if (JiveGlobals.getBooleanProperty("xmpp.socket.heapBuffer", true)) { IoBuffer.setUseDirectBuffer(false); IoBuffer.setAllocator(new SimpleBufferAllocator()); } }
Example 6
Source File: Channel.java From HeavenMS with GNU Affero General Public License v3.0 | 4 votes |
public Channel(final int world, final int channel, long startTime) { this.world = world; this.channel = channel; this.ongoingStartTime = startTime + 10000; // rude approach to a world's last channel boot time, placeholder for the 1st wedding reservation ever this.mapManager = new MapleMapManager(null, world, channel); try { port = 7575 + this.channel - 1; port += (world * 100); ip = YamlConfig.config.server.HOST + ":" + port; IoBuffer.setUseDirectBuffer(false); IoBuffer.setAllocator(new SimpleBufferAllocator()); acceptor = new NioSocketAcceptor(); acceptor.setHandler(new MapleServerHandler(world, channel)); acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 30); acceptor.getFilterChain().addLast("codec", (IoFilter) new ProtocolCodecFilter(new MapleCodecFactory())); acceptor.bind(new InetSocketAddress(port)); ((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true); for (MapleExpeditionType exped : MapleExpeditionType.values()) { expedType.add(exped); } if (Server.getInstance().isOnline()) { // postpone event loading to improve boot time... thanks Riizade, daronhudson for noticing slow startup times eventSM = new EventScriptManager(this, getEvents()); eventSM.init(); } else { String[] ev = {"0_EXAMPLE"}; eventSM = new EventScriptManager(this, ev); } dojoStage = new int[20]; dojoFinishTime = new long[20]; dojoTask = new ScheduledFuture<?>[20]; for(int i = 0; i < 20; i++) { dojoStage[i] = 0; dojoFinishTime[i] = 0; dojoTask[i] = null; } services = new ServicesManager(ChannelServices.OVERALL); System.out.println(" Channel " + getId() + ": Listening on port " + port); } catch (Exception e) { e.printStackTrace(); } }
Example 7
Source File: CachedIoBufferAllocator.java From jane with GNU Lesser General Public License v3.0 | 4 votes |
public static void globalSet(boolean useDirectBuffer, int maxPoolSize, int maxCachedBufferSize) { IoBuffer.setUseDirectBuffer(useDirectBuffer); IoBuffer.setAllocator( maxPoolSize > 0 && maxCachedBufferSize > 0 ? new CachedIoBufferAllocator(maxPoolSize, maxCachedBufferSize) : SimpleBufferAllocator.instance); }