using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using CommonLang.Protocol;
using CommonLang.Net;
namespace CommonServer.Server
{
///
/// 描述一个链接
///
public interface ISession : AbstractSession
{
///
/// Session ID
///
string ID { get; }
bool IsConnected { get; }
///
/// 总共发送字节数
///
long TotalSentBytes { get; }
///
/// 总共接收字节数
///
long TotalRecvBytes { get; }
ISessionListener Listener { get; }
///
/// 关闭此链接
///
///
///
bool Disconnect(bool force);
///
/// 发送消息【通知】
///
///
///
bool Send(IMessage message);
///
/// 发送消息【回馈】
///
///
///
///
bool SendResponse(IMessage request, IMessage response);
///
/// 获取远端地址
///
///
string GetRemoteAddress();
}
///
/// 服务端监听器
///
public interface ISessionListener
{
///
/// Session建立回调
///
///
void OnConnected(ISession session);
///
/// Session关闭回调
///
///
///
///
void OnDisconnected(ISession session, bool force, String reason);
///
/// 错误【编解码或者网络底层】
///
///
///
void OnError(ISession session, Exception err);
///
/// 消息发送成功
///
///
///
void OnSentMessage(ISession session, object message);
///
/// 消息接收到
///
///
///
void OnReceivedMessage(ISession session, object message);
}
}