123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Text;
- using SuperSocket.Common;
- using SuperSocket.SocketBase.Logging;
- using SuperSocket.SocketBase.Command;
- using SuperSocket.SocketBase.Config;
- using SuperSocket.SocketBase.Protocol;
- namespace SuperSocket.SocketBase
- {
- /// <summary>
- /// The basic interface for appSession
- /// </summary>
- public interface IAppSession : ISessionBase
- {
- /// <summary>
- /// Gets the app server.
- /// </summary>
- IAppServer AppServer { get; }
- /// <summary>
- /// Gets the socket session of the AppSession.
- /// </summary>
- ISocketSession SocketSession { get; }
- /// <summary>
- /// Gets the items.
- /// </summary>
- IDictionary<object, object> Items { get; }
- /// <summary>
- /// Gets the config of the server.
- /// </summary>
- IServerConfig Config { get; }
- /// <summary>
- /// Gets the local listening endpoint.
- /// </summary>
- IPEndPoint LocalEndPoint { get; }
- /// <summary>
- /// Gets or sets the last active time of the session.
- /// </summary>
- /// <value>
- /// The last active time.
- /// </value>
- DateTime LastActiveTime { get; set; }
- /// <summary>
- /// Gets the start time of the session.
- /// </summary>
- DateTime StartTime { get; }
- /// <summary>
- /// Closes this session.
- /// </summary>
- void Close();
- /// <summary>
- /// Closes the session by the specified reason.
- /// </summary>
- /// <param name="reason">The close reason.</param>
- void Close(CloseReason reason);
- /// <summary>
- /// Gets a value indicating whether this <see cref="IAppSession"/> is connected.
- /// </summary>
- /// <value>
- /// <c>true</c> if connected; otherwise, <c>false</c>.
- /// </value>
- bool Connected { get; }
- /// <summary>
- /// Gets or sets the charset which is used for transfering text message.
- /// </summary>
- /// <value>The charset.</value>
- Encoding Charset { get; set; }
- /// <summary>
- /// Gets or sets the previous command.
- /// </summary>
- /// <value>
- /// The prev command.
- /// </value>
- string PrevCommand { get; set; }
- /// <summary>
- /// Gets or sets the current executing command.
- /// </summary>
- /// <value>
- /// The current command.
- /// </value>
- string CurrentCommand { get; set; }
- /// <summary>
- /// Gets the logger assosiated with this session.
- /// </summary>
- ILog Logger { get; }
- /// <summary>
- /// Processes the request.
- /// </summary>
- /// <param name="readBuffer">The read buffer.</param>
- /// <param name="offset">The offset.</param>
- /// <param name="length">The length.</param>
- /// <param name="toBeCopied">if set to <c>true</c> [to be copied].</param>
- /// <returns>return offset delta of next receiving buffer</returns>
- int ProcessRequest(byte[] readBuffer, int offset, int length, bool toBeCopied);
- /// <summary>
- /// Starts the session.
- /// </summary>
- void StartSession();
- }
- /// <summary>
- /// The interface for appSession
- /// </summary>
- /// <typeparam name="TAppSession">The type of the app session.</typeparam>
- /// <typeparam name="TRequestInfo">The type of the request info.</typeparam>
- public interface IAppSession<TAppSession, TRequestInfo> : IAppSession
- where TRequestInfo : IRequestInfo
- where TAppSession : IAppSession, IAppSession<TAppSession, TRequestInfo>, new()
- {
- /// <summary>
- /// Initializes the specified session.
- /// </summary>
- /// <param name="server">The server.</param>
- /// <param name="socketSession">The socket session.</param>
- void Initialize(IAppServer<TAppSession, TRequestInfo> server, ISocketSession socketSession);
- }
- }
|