当前位置: 首页>>代码示例>>Java>>正文


Java IoSession.setIdleTime方法代码示例

本文整理汇总了Java中org.apache.mina.common.IoSession.setIdleTime方法的典型用法代码示例。如果您正苦于以下问题:Java IoSession.setIdleTime方法的具体用法?Java IoSession.setIdleTime怎么用?Java IoSession.setIdleTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.common.IoSession的用法示例。


在下文中一共展示了IoSession.setIdleTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sessionOpened

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
@Override
public void sessionOpened(final IoSession session) throws Exception {
	
    // Start of IP checking
    final String address = session.getRemoteAddress().toString().split(":")[0];
    final short port = Short.parseShort(session.getServiceAddress().toString().split(":")[1]);
    
    if (LoginServer.isShutdown()) {
        session.close();
        return;
    }

    // IV used to decrypt packets from client.
    final byte ivRecv[] = new byte[]{(byte) Randomizer.nextInt(255), (byte) Randomizer.nextInt(255), (byte) Randomizer.nextInt(255), (byte) Randomizer.nextInt(255)};
    
    // IV used to encrypt packets for client.
    final byte ivSend[] = new byte[]{(byte) Randomizer.nextInt(255), (byte) Randomizer.nextInt(255), (byte) Randomizer.nextInt(255), (byte) Randomizer.nextInt(255)};

    MapleClient client = new MapleClient(
            new MapleAESOFB(skey, ivSend, (short) (0xFFFF - ServerConstants.MAPLE_VERSION)),
            new MapleAESOFB(skey, ivRecv, ServerConstants.MAPLE_VERSION), session);
    client.setChannel(-1);

    MaplePacketDecoder.DecoderState decoderState = new MaplePacketDecoder.DecoderState();
    session.setAttribute(MaplePacketDecoder.DECODER_STATE_KEY, decoderState);
    
    session.write(LoginPacket.getHello(ServerConstants.MAPLE_VERSION, ivSend, ivRecv));
    session.setAttribute(MapleClient.CLIENT_KEY, client);
    session.setIdleTime(IdleStatus.READER_IDLE, 60);
    session.setIdleTime(IdleStatus.WRITER_IDLE, 60);

    System.out.println("Connection Established " + address + ":"+port);
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:34,代码来源:MapleServerHandler.java

示例2: sessionOpened

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
@Override
public void sessionOpened(final IoSession session) throws Exception {
    //log.info("IoSession with {} opened", session.getRemoteAddress());
    if (channel > -1) {
        if (ChannelServer.getInstance(channel).isShutdown()) {
            session.close();
            return;
        }
    }
    final byte[] key = {
        (byte) 0x13, (byte) 0x00, (byte) 0x00, (byte) 0x00,
        (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00,
        (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00,
        (byte) 0xB4, (byte) 0x00, (byte) 0x00, (byte) 0x00,
        (byte) 0x1B, (byte) 0x00, (byte) 0x00, (byte) 0x00,
        (byte) 0x0F, (byte) 0x00, (byte) 0x00, (byte) 0x00,
        (byte) 0x33, (byte) 0x00, (byte) 0x00, (byte) 0x00,
        (byte) 0x52, (byte) 0x00, (byte) 0x00, (byte) 0x00
    };
    final byte[] ivRecv = {(byte) 70, (byte) 114, (byte) 122, (byte) 82};
    final byte[] ivSend = {(byte) 82, (byte) 48, (byte) 120, (byte) 115};
    ivRecv[3] = (byte) (Math.random() * 255.0d);
    ivSend[3] = (byte) (Math.random() * 255.0d);
    final MapleAESOFB sendCypher = new MapleAESOFB(key, ivSend, (short) (0xFFFF - MAPLE_VERSION));
    final MapleAESOFB recvCypher = new MapleAESOFB(key, ivRecv, MAPLE_VERSION);
    final MapleClient client = new MapleClient(sendCypher, recvCypher, session);
    client.setChannel(channel);
    session.write(MaplePacketCreator.getHello(MAPLE_VERSION, ivSend, ivRecv, false));
    session.setAttribute(MapleClient.CLIENT_KEY, client);
    session.setIdleTime(IdleStatus.READER_IDLE, 30);
    session.setIdleTime(IdleStatus.WRITER_IDLE, 30);
}
 
开发者ID:NoetherEmmy,项目名称:intransigentms,代码行数:33,代码来源:MapleServerHandler.java


注:本文中的org.apache.mina.common.IoSession.setIdleTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。