本文整理汇总了Java中org.apache.mina.core.buffer.IoBuffer.setUseDirectBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java IoBuffer.setUseDirectBuffer方法的具体用法?Java IoBuffer.setUseDirectBuffer怎么用?Java IoBuffer.setUseDirectBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mina.core.buffer.IoBuffer
的用法示例。
在下文中一共展示了IoBuffer.setUseDirectBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
/**
* start Mina serversocket
* @throws Exception
*/
public void start() throws Exception {
IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());
acceptor = new NioSocketAcceptor(pool);
acceptor.setReuseAddress(true);
acceptor.getSessionConfig().setAll(getSessionConfig());
int serverPort = GateServerConfig.serverPort;
logger.info("socket server start at port:{},正在监听客户端的连接...", serverPort);
DefaultIoFilterChainBuilder filterChain = acceptor.getFilterChain();
filterChain.addLast("codec", new ProtocolCodecFilter(MessageCodecFactory.getInstance()));
acceptor.setHandler( new ServerSocketIoHandler() );//指定业务逻辑处理器
acceptor.setDefaultLocalAddress(new InetSocketAddress(serverPort) );//设置端口号
acceptor.bind();//启动监听
}
示例2: Channel
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
public Channel(final int world, final int channel) {
this.world = world;
this.channel = channel;
this.mapFactory = new MapleMapFactory(MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Map.wz")), MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/String.wz")), world, channel);
try {
eventSM = new EventScriptManager(this, ServerConstants.EVENTS.split(" "));
port = 7575 + this.channel - 1;
port += (world * 100);
ip = ServerConstants.HOST + ":" + port;
IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());
acceptor = new NioSocketAcceptor();
TimerManager.getInstance().register(new respawnMaps(), 10000);
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);
eventSM.init();
System.out.println(" Channel " + getId() + ": Listening on port " + port);
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: startGMServer
import org.apache.mina.core.buffer.IoBuffer; //导入方法依赖的package包/类
public static void startGMServer() {
IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());
acceptor = new NioSocketAcceptor();
acceptor.setHandler(new GMServerHandler());
acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 30);
acceptor.getFilterChain().addLast("codec", (IoFilter) new ProtocolCodecFilter(new GMCodecFactory()));
((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true);
try {
acceptor.bind(new InetSocketAddress(5252));
System.out.println("\r\nGM Server online : Listening on port 5252.");
} catch (Exception e) {
System.out.println("Failed binding the GM Server to port : 5252");
}
for (World w : Server.getInstance().getWorlds()) {//For when
for (Channel c : w.getChannels()) {
for (MapleCharacter chr : c.getPlayerStorage().getAllCharacters()) {
if (chr.isGM()) {
inGame.put(chr.getName(), chr.getClient().getSession());
}
}
}
}
started = true;
}