本文整理汇总了C#中IoSession.Close方法的典型用法代码示例。如果您正苦于以下问题:C# IoSession.Close方法的具体用法?C# IoSession.Close怎么用?C# IoSession.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IoSession
的用法示例。
在下文中一共展示了IoSession.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SessionCreated
public override void SessionCreated(INextFilter nextFilter, IoSession session)
{
if (!IsConnectionOk(session))
{
Debug.WriteLine("Connections coming in too fast; closing.");
session.Close(true);
}
base.SessionCreated(nextFilter, session);
}
示例2: SessionCreated
/// <inheritdoc/>
public override void SessionCreated(INextFilter nextFilter, IoSession session)
{
if (!IsConnectionOk(session))
{
if (log.IsWarnEnabled)
log.Warn("Connections coming in too fast; closing.");
session.Close(true);
}
base.SessionCreated(nextFilter, session);
}
示例3: ExceptionCaught
public override void ExceptionCaught(INextFilter nextFilter, IoSession session, Exception cause)
{
Log.Error(ErrorCode.UnhandledExceptionCaught, cause);
var counter = session.GetAttribute<int>(KeyName.SESSION_ERROR_COUNTER);
if (counter >= MAX_UNCAUGHT_SESSION_ERROR_COUNT) session.Close(true);
else
{
session.SetAttribute(KeyName.SESSION_ERROR_COUNTER, ++counter);
base.ExceptionCaught(nextFilter, session, cause);
}
}
示例4: MessageReceived
/// <summary>
/// If the message is 'quit', we exit by closing the session. Otherwise,
/// we return the current date.
/// </summary>
public override void MessageReceived(IoSession session, Object message)
{
String str = message.ToString();
// "Quit" ? let's get out ...
if (str.Trim().Equals("quit", StringComparison.OrdinalIgnoreCase))
{
session.Close(true);
return;
}
// Send the current date back to the client
session.Write(DateTime.Now.ToString());
Console.WriteLine("Message written...");
}
示例5: ExceptionCaught
public override void ExceptionCaught(IoSession session, Exception cause)
{
IOException ioe = cause as IOException;
if (ioe != null)
{
IoSessionStream input = session.GetAttribute<IoSessionStream>(KEY_IN);
if (input != null)
{
input.Exception = ioe;
return;
}
}
Debug.WriteLine("Unexpected exception. {0}", cause);
session.Close(true);
}
示例6: MessageReceived
public override void MessageReceived(IoSession session, Object message)
{
Console.WriteLine("Player-" + id + ": RCVD " + message);
TennisBall ball = (TennisBall)message;
// Stroke: TTL decreases and PING/PONG state changes.
ball = ball.Stroke();
if (ball.TTL > 0)
{
// If the ball is still alive, pass it back to peer.
session.Write(ball);
}
else
{
// If the ball is dead, this player loses.
Console.WriteLine("Player-" + id + ": LOSE");
session.Close(true);
}
}
示例7: FinishSessionInitialization0
/// <inheritdoc/>
protected override void FinishSessionInitialization0(IoSession session, IoFuture future)
{
// In case that IConnectFuture.Cancel() is invoked before
// SetSession() is invoked, add a listener that closes the
// connection immediately on cancellation.
future.Complete += (s, e) =>
{
if (((IConnectFuture)e.Future).Canceled)
session.Close(true);
};
}
示例8: InputClosed
/// <inheritdoc/>
public void InputClosed(IoSession session)
{
session.Close(true);
}
示例9: BlockSession
private void BlockSession(IoSession session)
{
if (log.IsWarnEnabled)
log.Warn("Remote address in the blacklist; closing.");
session.Close(true);
}
示例10: KeepAliveRequestTimedOut
public void KeepAliveRequestTimedOut(KeepAliveFilter filter, IoSession session)
{
Debug.WriteLine("Closing the session because a keep-alive response message was not received within {0} second(s).",
filter.RequestTimeout);
session.Close(true);
}
示例11: ExceptionCaught
/// <inheritdoc/>
public override void ExceptionCaught(IoSession session, Exception cause)
{
IOException ioe = cause as IOException;
if (ioe != null)
{
IoSessionStream input = session.GetAttribute<IoSessionStream>(KEY_IN);
if (input != null)
{
input.Exception = ioe;
return;
}
}
if (log.IsWarnEnabled)
log.Warn("Unexpected exception.", cause);
session.Close(true);
}
示例12: SessionIdle
public override void SessionIdle(INextFilter nextFilter, IoSession session, IdleStatus status)
{
if (status == IdleStatus.ReaderIdle) session.Close(true);
}
示例13: ExceptionCaught
public override void ExceptionCaught(IoSession session, Exception cause)
{
session.Close(true);
}
示例14: KeepAliveRequestTimedOut
public void KeepAliveRequestTimedOut(KeepAliveFilter filter, IoSession session)
{
if (log.IsWarnEnabled)
log.WarnFormat("Closing the session because a keep-alive response message was not received within {0} second(s).",
filter.RequestTimeout);
session.Close(true);
}
示例15: ExceptionCaught
public override void ExceptionCaught(IoSession session, Exception cause)
{
Console.WriteLine(cause);
session.Close(true);
}