Session 类
网络会话的基类,用于管理网络通信。
继承成员
命名空间: Fantasy.Network
程序集: Fantasy.Net.dll
语法
public class Session : Entity, IEntity, IPool, ISupportedMultiEntity, IDisposable
字段
| 编辑本文 查看源代码RequestCallback
声明
public readonly Dictionary<long, FTask<IResponse>> RequestCallback
字段值
类型 | 描述 |
---|---|
Dictionary<long, FTask<IResponse>> |
属性
| 编辑本文 查看源代码Channel
关联的网络连接通道
声明
public INetworkChannel Channel { get; }
属性值
类型 | 描述 |
---|---|
INetworkChannel |
RemoteEndPoint
当前Session的终结点信息
声明
public IPEndPoint RemoteEndPoint { get; }
属性值
类型 | 描述 |
---|---|
IPEndPoint |
方法
| 编辑本文 查看源代码Call(IRequest, long)
发送一个RPC消息
声明
public virtual FTask<IResponse> Call(IRequest request, long routeId = 0)
参数
类型 | 名称 | 描述 |
---|---|---|
IRequest | request | 请求消息的实例 |
long | routeId | routeId |
返回
类型 | 描述 |
---|---|
FTask<IResponse> |
Call(IRouteRequest, long)
发送一个RPC消息
声明
public virtual FTask<IResponse> Call(IRouteRequest request, long routeId = 0)
参数
类型 | 名称 | 描述 |
---|---|---|
IRouteRequest | request | 请求Route消息的实例 |
long | routeId | routeId |
返回
类型 | 描述 |
---|---|
FTask<IResponse> |
Dispose()
销毁一个Session,当执行了这个方法会自动断开网络的连接。
声明
public override void Dispose()
重写
| 编辑本文 查看源代码Send(IMessage, uint, long)
发送一个消息
声明
public virtual void Send(IMessage message, uint rpcId = 0, long routeId = 0)
参数
类型 | 名称 | 描述 |
---|---|---|
IMessage | message | 消息的实例 |
uint | rpcId | 如果是RPC消息需要传递一个RPCId |
long | routeId | routeId |
Send(IRouteMessage, uint, long)
发送一个消息
声明
public virtual void Send(IRouteMessage routeMessage, uint rpcId = 0, long routeId = 0)
参数
类型 | 名称 | 描述 |
---|---|---|
IRouteMessage | routeMessage | 消息的实例,不同的是这个是发送Route消息使用的 |
uint | rpcId | 如果是RPC消息需要传递一个RPCId |
long | routeId | routeId |
Send(ProcessPackInfo, uint, long)
发送一个消息,框架内部使用建议不要用这个方法。
声明
public virtual void Send(ProcessPackInfo packInfo, uint rpcId = 0, long routeId = 0)
参数
类型 | 名称 | 描述 |
---|---|---|
ProcessPackInfo | packInfo | 一个ProcessPackInfo消息包 |
uint | rpcId | 如果是RPC消息需要传递一个RPCId |
long | routeId | routeId |
Send(MemoryStreamBuffer, uint, long)
发送一个消息
声明
public virtual void Send(MemoryStreamBuffer memoryStream, uint rpcId = 0, long routeId = 0)
参数
类型 | 名称 | 描述 |
---|---|---|
MemoryStreamBuffer | memoryStream | 需要发送的MemoryStreamBuffer |
uint | rpcId | 如果是RPC消息需要传递一个RPCId |
long | routeId | routeId |
Send(uint, long, Type, APackInfo)
发送一个消息,框架内部使用建议不要用这个方法。
声明
public virtual void Send(uint rpcId, long routeId, Type messageType, APackInfo packInfo)
参数
类型 | 名称 | 描述 |
---|---|---|
uint | rpcId | 如果是RPC消息需要传递一个RPCId |
long | routeId | routeId |
Type | messageType | 消息的类型 |
APackInfo | packInfo | packInfo消息包 |
事件
| 编辑本文 查看源代码OnDispose
Session的Dispose委托
声明
public event Action OnDispose
事件类型
类型 | 描述 |
---|---|
Action |