using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using SuperSocket.Common;
using SuperSocket.SocketBase.Command;
using SuperSocket.SocketBase.Config;
using SuperSocket.SocketBase.Logging;
using SuperSocket.SocketBase.Protocol;
using SuperSocket.SocketBase.Provider;
namespace SuperSocket.SocketBase
{
///
/// The interface for AppServer
///
public interface IAppServer : IWorkItem, ILoggerProvider
{
///
/// Gets the started time.
///
///
/// The started time.
///
DateTime StartedTime { get; }
///
/// Gets or sets the listeners.
///
///
/// The listeners.
///
ListenerInfo[] Listeners { get; }
///
/// Gets the Receive filter factory.
///
object ReceiveFilterFactory { get; }
///
/// Gets the certificate of current server.
///
X509Certificate Certificate { get; }
///
/// Gets the transfer layer security protocol.
///
SslProtocols BasicSecurity { get; }
///
/// Creates the app session.
///
/// The socket session.
///
IAppSession CreateAppSession(ISocketSession socketSession);
///
/// Registers the new created app session into the appserver's session container.
///
/// The session.
///
bool RegisterSession(IAppSession session);
///
/// Gets the app session by ID.
///
/// The session ID.
///
IAppSession GetSessionByID(string sessionID);
///
/// Resets the session's security protocol.
///
/// The session.
/// The security protocol.
void ResetSessionSecurity(IAppSession session, SslProtocols security);
///
/// Gets the log factory.
///
ILogFactory LogFactory { get; }
}
///
/// The raw data processor
///
/// The type of the app session.
public interface IRawDataProcessor
where TAppSession : IAppSession
{
///
/// Gets or sets the raw binary data received event handler.
/// TAppSession: session
/// byte[]: receive buffer
/// int: receive buffer offset
/// int: receive lenght
/// bool: whether process the received data further
///
event Func RawDataReceived;
}
///
/// The interface for AppServer
///
/// The type of the app session.
public interface IAppServer : IAppServer
where TAppSession : IAppSession
{
///
/// Gets the matched sessions from sessions snapshot.
///
/// The prediction critera.
///
IEnumerable GetSessions(Func critera);
///
/// Gets all sessions in sessions snapshot.
///
///
IEnumerable GetAllSessions();
///
/// Gets/sets the new session connected event handler.
///
event SessionHandler NewSessionConnected;
///
/// Gets/sets the session closed event handler.
///
event SessionHandler SessionClosed;
}
///
/// The interface for AppServer
///
/// The type of the app session.
/// The type of the request info.
public interface IAppServer : IAppServer
where TRequestInfo : IRequestInfo
where TAppSession : IAppSession, IAppSession, new()
{
///
/// Occurs when [request comming].
///
event RequestHandler NewRequestReceived;
}
///
/// The interface for handler of session request
///
/// The type of the request info.
public interface IRequestHandler
where TRequestInfo : IRequestInfo
{
///
/// Executes the command.
///
/// The session.
/// The request info.
void ExecuteCommand(IAppSession session, TRequestInfo requestInfo);
}
///
/// SocketServer Accessor interface
///
public interface ISocketServerAccessor
{
///
/// Gets the socket server.
///
///
/// The socket server.
///
ISocketServer SocketServer { get; }
}
///
/// The basic interface for RemoteCertificateValidator
///
public interface IRemoteCertificateValidator
{
///
/// Validates the remote certificate
///
/// The session.
/// The sender.
/// The certificate.
/// The chain.
/// The SSL policy errors.
///
bool Validate(IAppSession session, object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors);
}
}