using System; using System.Collections.Generic; using System.Text; using CommonLang.Protocol; using System.Collections.Specialized; using CommonLang.Net; namespace CommonServer.Server { /// /// 服务器监听器 /// public interface IServerListener { /// /// 服务器初始化回调 /// /// void OnInit(IServer server); /// /// 服务器关闭回调 /// void OnDestory(); /// /// 一个链接建立成功 /// /// /// ISessionListener OnSessionConnected(ISession session); } /// /// /// public interface IServerFactory { IServer CreateServer(INetPackageCodec codec); } public interface IServer { /// /// 客户端连接套接字 /// string ClientConnectString { get; } /// /// 获取编解码器 /// INetPackageCodec PackageCodec { get; } /// /// 获取当前已连接数 /// int SessionCount { get; } /// /// 启动服务器 /// /// /// void Open(IDictionary config, IServerListener listener); /// /// 关闭服务器 /// void Dispose(); /// /// 广播消息 /// /// void Broadcast(IMessage message); /// /// 服务器是否有此链接 /// /// /// bool HasSession(ISession session); /// /// 根据 Session ID 获取链接 /// /// /// ISession GetSessionByID(string sessionID); /// /// 获取所有链接 /// /// IEnumerable GetSessions(); long TotalSentBytes { get; } long TotalRecvBytes { get; } void SetEmulateLaggingMS(int min, int max); void GetEmulateLaggingMS(out int min, out int max); } }