MailServer/MailServer/Misc/SocketServer/SocketServerSession/SocketServerSession.Properties.cs
2010-07-10 00:32:10 +00:00

150 lines
4.0 KiB
C#

using System;
using System.Net;
namespace MailServer.Misc.SocketServer
{
public abstract partial class SocketServerSession
{
/// <summary>
/// Gets session ID.
/// </summary>
public string SessionID
{
get { return m_SessionID; }
}
/// <summary>
/// Gets session start time.
/// </summary>
public DateTime SessionStartTime
{
get { return m_SessionStartTime; }
}
/// <summary>
/// Gets if session is authenticated.
/// </summary>
public bool Authenticated
{
get
{
if (m_UserName.Length > 0)
{
return true;
}
else
{
return false;
}
}
}
/// <summary>
/// Gets authenticated user name.
/// </summary>
public string UserName
{
get { return m_UserName; }
}
/// <summary>
/// Gets how many seconds has left before timout is triggered.
/// </summary>
public int ExpectedTimeout
{
get
{
return (int)((m_pServer.SessionIdleTimeOut - ((DateTime.Now.Ticks - SessionLastDataTime.Ticks) / 10000)) / 1000);
}
}
/// <summary>
/// Gets last data activity time.
/// </summary>
public DateTime SessionLastDataTime
{
get
{
if (m_pSocket == null)
{
return DateTime.MinValue;
}
else
{
return m_pSocket.LastActivity;
}
}
}
/// <summary>
/// Gets EndPoint which accepted conection.
/// </summary>
public IPEndPoint LocalEndPoint
{
get { return (IPEndPoint)m_pSocket.LocalEndPoint; }
}
/// <summary>
/// Gets connected Host(client) EndPoint.
/// </summary>
public IPEndPoint RemoteEndPoint
{
get
{
try
{
return (IPEndPoint)m_pSocket.RemoteEndPoint;
}
catch
{ // Socket closed/disposed already
return null;
}
}
}
/// <summary>
/// Gets or sets custom user data.
/// </summary>
public object Tag
{
get { return m_Tag; }
set { m_Tag = value; }
}
/// <summary>
/// Gets log entries that are currently in log buffer.
/// </summary>
public SocketLogger SessionActiveLog
{
get { return m_pSocket.Logger; }
}
/// <summary>
/// Gets how many bytes are readed through this session.
/// </summary>
public long ReadedCount
{
get { return m_pSocket.ReadedCount; }
}
/// <summary>
/// Gets how many bytes are written through this session.
/// </summary>
public long WrittenCount
{
get { return m_pSocket.WrittenCount; }
}
/// <summary>
/// Gets if the connection is an SSL connection.
/// </summary>
public bool IsSecureConnection
{
get { return m_pSocket.SSL; }
}
/// <summary>
/// Gets access to SocketEx.
/// </summary>
protected SocketEx Socket
{
get { return m_pSocket; }
}
/// <summary>
/// Gets access to BindInfo what accepted socket.
/// </summary>
protected IPBindInfo BindInfo
{
get { return m_pBindInfo; }
}
}
}