當前位置: 首頁>>代碼示例>>Java>>正文


Java IoBuffer.setAllocator方法代碼示例

本文整理匯總了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();//啟動監聽

}
 
開發者ID:kingston-csj,項目名稱:jforgame,代碼行數:22,代碼來源:SocketServer.java

示例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();
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:27,代碼來源:Channel.java

示例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;
    }
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:28,代碼來源:GMServer.java


注:本文中的org.apache.mina.core.buffer.IoBuffer.setAllocator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。