本文整理匯總了Java中org.apache.mina.core.buffer.IoBuffer.setAllocator方法的典型用法代碼示例。如果您正苦於以下問題:Java IoBuffer.setAllocator方法的具體用法?Java IoBuffer.setAllocator怎麽用?Java IoBuffer.setAllocator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.mina.core.buffer.IoBuffer
的用法示例。
在下文中一共展示了IoBuffer.setAllocator方法的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;
}