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


Java IoSession.containsAttribute方法代码示例

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


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

示例1: decode

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void decode( IoSession session, IoBuffer in, ProtocolDecoderOutput out ) throws Exception
{
    @SuppressWarnings("unchecked")
    LdapMessageContainer<MessageDecorator<? extends Message>> messageContainer =
        ( LdapMessageContainer<MessageDecorator<? extends Message>> )
        session.getAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR );

    if ( session.containsAttribute( LdapDecoder.MAX_PDU_SIZE_ATTR ) )
    {
        int maxPDUSize = ( Integer ) session.getAttribute( LdapDecoder.MAX_PDU_SIZE_ATTR );

        messageContainer.setMaxPDUSize( maxPDUSize );
    }

    List<Message> decodedMessages = new ArrayList<>();
    ByteBuffer buf = in.buf();

    decode( buf, messageContainer, decodedMessages );

    for ( Message message : decodedMessages )
    {
        out.write( message );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:LdapProtocolDecoder.java

示例2: doFilterWrite

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
protected Object doFilterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
        throws IOException {
    if (!compressOutbound) {
        return null;
    }

    if (session.containsAttribute(DISABLE_COMPRESSION_ONCE)) {
        // Remove the marker attribute because it is temporary.
        session.removeAttribute(DISABLE_COMPRESSION_ONCE);
        return null;
    }

    Zlib deflater = (Zlib) session.getAttribute(DEFLATER);
    if (deflater == null) {
        throw new IllegalStateException();
    }

    IoBuffer inBuffer = (IoBuffer) writeRequest.getMessage();
    if (!inBuffer.hasRemaining()) {
        // Ignore empty buffers
        return null;
    } else {
        return deflater.deflate(inBuffer);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:CompressionFilter.java

示例3: initiateClosure

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
private WriteFuture initiateClosure(NextFilter nextFilter, IoSession session) throws SSLException {
    SslHandler handler = getSslSessionHandler(session);

    // if already shut down
    if (!handler.closeOutbound()) {
        return DefaultWriteFuture.newNotWrittenFuture(session, new IllegalStateException(
                "SSL session is shut down already."));
    }

    // there might be data to write out here?
    WriteFuture future = handler.writeNetBuffer(nextFilter);

    if (future == null) {
        future = DefaultWriteFuture.newWrittenFuture(session);
    }

    if (handler.isInboundDone()) {
        handler.destroy();
    }

    if (session.containsAttribute(USE_NOTIFICATION)) {
        handler.scheduleMessageReceived(nextFilter, SESSION_UNSECURED);
    }

    return future;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:SslFilter.java

示例4: sessionIdle

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
public void sessionIdle(IoSession session, IdleStatus status)throws Exception {
	logger.info("客户端sessionIdle, " + (System.currentTimeMillis() - session.getLastReadTime()) + "毫秒没有上行。" + session.getRemoteAddress());
  		if((System.currentTimeMillis()-session.getLastReadTime())>1000*60*10){
  			Object userID = (Object)0;
  			if(session.containsAttribute("UserID")){    			
  				 userID = session.getAttribute("UserID");
  			}
		logger.info(" Player["+userID.toString()+"] -------------------------------------------Out of time, close user session  lastReadTime:"+session.getLastReadTime()+"["+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:ms").format(new Date(session.getLastReadTime()))+"]   now:"+System.currentTimeMillis()+"["+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:ms").format(new Date(System.currentTimeMillis()))+"]  session:"+session.getRemoteAddress());
		logger.info(session.getId()+"  -----------------------------------------Out of time, close user session");
		logger.info("System.currentTimeMillis():"+format(System.currentTimeMillis()));
		logger.info("session.getLastIoTime():"+format(session.getLastIoTime()));
		logger.info("session.getLastBothIdleTime():"+format(session.getLastBothIdleTime()));
		logger.info("session.getLastReaderIdleTime():"+format(session.getLastReaderIdleTime()));
		logger.info("session.getLastReadTime():"+format(session.getLastReadTime()));
		logger.info("session.getLastWriterIdleTime():"+format(session.getLastWriterIdleTime()));
		logger.info("session.getLastWriteTime():"+format(session.getLastWriteTime()));
		session.closeOnFlush();
   	}
}
 
开发者ID:langxianwei,项目名称:iot-plat,代码行数:20,代码来源:ServerHandler.java

示例5: getCharsetEncoder

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
private CharsetEncoder getCharsetEncoder ( final IoSession session )
{
    if ( session.containsAttribute ( "charsetEncoder" ) )
    {
        return (CharsetEncoder)session.getAttribute ( "charsetEncoder" );
    }

    final CharsetEncoder encoder = Charset.forName ( "UTF-8" ).newEncoder ();
    session.setAttribute ( "charsetEncoder", encoder );
    return encoder;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:MessageChannelCodecFilter.java

示例6: getCharsetDecoder

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
private CharsetDecoder getCharsetDecoder ( final IoSession session )
{
    if ( session.containsAttribute ( "charsetDecoder" ) )
    {
        return (CharsetDecoder)session.getAttribute ( "charsetDecoder" );
    }

    final CharsetDecoder decoder = Charset.forName ( "UTF-8" ).newDecoder ();
    session.setAttribute ( "charsetDecoder", decoder );
    return decoder;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:MessageChannelCodecFilter.java

示例7: sessionIdle

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception {
    if (status == interestedIdleStatus) {
        if (!session.containsAttribute(WAITING_FOR_RESPONSE)) {
            Object pingMessage = messageFactory.getRequest(session);
            if (pingMessage != null) {
                nextFilter.filterWrite(session, new DefaultWriteRequest(pingMessage));

                // If policy is OFF, there's no need to wait for
                // the response.
                if (getRequestTimeoutHandler() != KeepAliveRequestTimeoutHandler.DEAF_SPEAKER) {
                    markStatus(session);
                    if (interestedIdleStatus == IdleStatus.BOTH_IDLE) {
                        session.setAttribute(IGNORE_READER_IDLE_ONCE);
                    }
                } else {
                    resetStatus(session);
                }
            }
        } else {
            handlePingTimeout(session);
        }
    } else if (status == IdleStatus.READER_IDLE) {
        if (session.removeAttribute(IGNORE_READER_IDLE_ONCE) == null) {
            if (session.containsAttribute(WAITING_FOR_RESPONSE)) {
                handlePingTimeout(session);
            }
        }
    }

    if (forwardEvent) {
        nextFilter.sessionIdle(session, status);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:35,代码来源:KeepAliveFilter.java

示例8: filterWrite

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws SSLException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("{}: Writing Message : {}", getSessionInfo(session), writeRequest);
    }

    boolean needsFlush = true;
    SslHandler handler = getSslSessionHandler(session);
    synchronized (handler) {
        if (!isSslStarted(session)) {
            handler.scheduleFilterWrite(nextFilter, writeRequest);
        }
        // Don't encrypt the data if encryption is disabled.
        else if (session.containsAttribute(DISABLE_ENCRYPTION_ONCE)) {
            // Remove the marker attribute because it is temporary.
            session.removeAttribute(DISABLE_ENCRYPTION_ONCE);
            handler.scheduleFilterWrite(nextFilter, writeRequest);
        } else {
            // Otherwise, encrypt the buffer.
            IoBuffer buf = (IoBuffer) writeRequest.getMessage();

            if (handler.isWritingEncryptedData()) {
                // data already encrypted; simply return buffer
                handler.scheduleFilterWrite(nextFilter, writeRequest);
            } else if (handler.isHandshakeComplete()) {
                // SSL encrypt
                int pos = buf.position();
                handler.encrypt(buf.buf());
                buf.position(pos);
                IoBuffer encryptedBuffer = handler.fetchOutNetBuffer();
                handler.scheduleFilterWrite(nextFilter, new EncryptedWriteRequest(writeRequest, encryptedBuffer));
            } else {
                if (session.isConnected()) {
                    // Handshake not complete yet.
                    handler.schedulePreHandshakeWriteRequest(nextFilter, writeRequest);
                }
                needsFlush = false;
            }
        }
    }

    if (needsFlush) {
        handler.flushScheduledEvents();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:46,代码来源:SslFilter.java

示例9: isLittleEndian

import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
public static boolean isLittleEndian ( final IoSession session )
{
    return session.containsAttribute ( ATTR_LITTLE_ENDIAN );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:5,代码来源:Sessions.java


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