本文整理汇总了Java中org.apache.mina.core.session.IoSession.removeAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java IoSession.removeAttribute方法的具体用法?Java IoSession.removeAttribute怎么用?Java IoSession.removeAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mina.core.session.IoSession
的用法示例。
在下文中一共展示了IoSession.removeAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sessionClosed
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void sessionClosed(IoSession session) throws Exception {
MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
if (client != null) {
try {
boolean inCashShop = false;
if (client.getPlayer() != null) {
inCashShop = client.getPlayer().getCashShop().isOpened();
}
client.disconnect(false, inCashShop);
} catch (Throwable t) {
FilePrinter.printError(FilePrinter.ACCOUNT_STUCK, t);
} finally {
session.close();
session.removeAttribute(MapleClient.CLIENT_KEY);
//client.empty();
}
}
super.sessionClosed(session);
}
示例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);
}
}
示例3: finishDecode
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void finishDecode ( final IoSession session, final ProtocolDecoderOutput out ) throws Exception
{
// remove the context from the session and kill the cyclic check
final Context ctx = (Context)session.removeAttribute ( CONTEXT );
if ( ctx != null )
{
unregisterContext ( ctx );
ctx.dispose ();
}
}
示例4: execute
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
public void execute(NextCommand next, IoSession session, Object message) throws Exception {
if (next != null) {
session.setAttribute(NEXT_COMMAND, next);
}
try {
callNextCommand(head, session, message);
} finally {
session.removeAttribute(NEXT_COMMAND);
}
}
示例5: messageSent
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {
T stream = getMessageClass().cast(session.getAttribute(CURRENT_STREAM));
if (stream == null) {
nextFilter.messageSent(session, writeRequest);
} else {
IoBuffer buffer = getNextBuffer(stream);
if (buffer == null) {
// End of stream reached.
session.removeAttribute(CURRENT_STREAM);
WriteRequest currentWriteRequest = (WriteRequest) session.removeAttribute(CURRENT_WRITE_REQUEST);
// Write queued WriteRequests.
Queue<WriteRequest> queue = removeWriteRequestQueue(session);
if (queue != null) {
WriteRequest wr = queue.poll();
while (wr != null) {
filterWrite(nextFilter, session, wr);
wr = queue.poll();
}
}
currentWriteRequest.getFuture().setWritten();
nextFilter.messageSent(session, currentWriteRequest);
} else {
nextFilter.filterWrite(session, new DefaultWriteRequest(buffer));
}
}
}
示例6: 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);
}
}
示例7: sessionCreated
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception {
try {
session.getHandler().sessionCreated(session);
} finally {
// Notify the related future.
ConnectFuture future = (ConnectFuture) session.removeAttribute(SESSION_CREATED_FUTURE);
if (future != null) {
future.setSession(session);
}
}
}
示例8: onPreRemove
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void onPreRemove(IoFilterChain parent, String name, NextFilter nextFilter) throws SSLException {
IoSession session = parent.getSession();
stopSsl(session);
session.removeAttribute(NEXT_FILTER);
session.removeAttribute(SSL_HANDLER);
}
示例9: disposeEncoder
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
/**
* Dispose the encoder, removing its instance from the
* session's attributes, and calling the associated
* dispose method.
*/
private void disposeEncoder(IoSession session) {
ProtocolEncoder encoder = (ProtocolEncoder) session.removeAttribute(ENCODER);
if (encoder == null) {
return;
}
try {
encoder.dispose(session);
} catch (Throwable t) {
LOGGER.warn("Failed to dispose: " + encoder.getClass().getName() + " (" + encoder + ')');
}
}
示例10: disposeDecoder
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
/**
* Dispose the decoder, removing its instance from the
* session's attributes, and calling the associated
* dispose method.
*/
private void disposeDecoder(IoSession session) {
ProtocolDecoder decoder = (ProtocolDecoder) session.removeAttribute(DECODER);
if (decoder == null) {
return;
}
try {
decoder.dispose(session);
} catch (Throwable t) {
LOGGER.warn("Failed to dispose: " + decoder.getClass().getName() + " (" + decoder + ')');
}
}
示例11: dispose
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@Override
public void dispose ( final IoSession session ) throws Exception
{
// remove the context from the session and kill the cyclic check
final Context ctx = (Context)session.getAttribute ( CONTEXT );
if ( ctx != null )
{
unregisterContext ( ctx );
ctx.dispose ();
session.removeAttribute ( CONTEXT );
}
}
示例12: dispose
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void dispose(IoSession session) throws Exception {
Context ctx = (Context) session.getAttribute(CONTEXT);
if (ctx != null) {
session.removeAttribute(CONTEXT);
}
}
示例13: clearSessionBuffer
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
private void clearSessionBuffer ( final IoSession session )
{
// simply remove the session buffer
session.removeAttribute ( SESSION_BUFFER_ATTR );
}
示例14: removeWriteRequestQueue
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Queue<WriteRequest> removeWriteRequestQueue(IoSession session) {
return (Queue<WriteRequest>) session.removeAttribute(WRITE_REQUEST_QUEUE);
}
示例15: resetStatus
import org.apache.mina.core.session.IoSession; //导入方法依赖的package包/类
private void resetStatus(IoSession session) {
session.getConfig().setReaderIdleTime(0);
session.getConfig().setWriterIdleTime(0);
session.getConfig().setIdleTime(interestedIdleStatus, getRequestInterval());
session.removeAttribute(WAITING_FOR_RESPONSE);
}