完成离线消息发送和上线获取离线消息
This commit is contained in:
@@ -6,6 +6,21 @@ namespace NB.Chat;
|
||||
|
||||
public static class ChatUnitManageComponentSystem
|
||||
{
|
||||
#region 消息缓存
|
||||
|
||||
/// <summary>
|
||||
/// 离线消息,进入待领取队列
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <param name="targetId"></param>
|
||||
/// <param name="message"></param>
|
||||
public static void SaveOfflineMessage(this ChatUnitManageComponent self, long targetId, ChatMessageInfo message)
|
||||
{
|
||||
self.NotSendMessage.Add(targetId, message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 上线下线
|
||||
|
||||
/// <summary>
|
||||
@@ -15,7 +30,8 @@ public static class ChatUnitManageComponentSystem
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="roleSimpleInfo"></param>
|
||||
/// <param name="gateRouteId"></param>
|
||||
public static async FTask<ChatUnit?> Online(this ChatUnitManageComponent self, Scene scene, RoleSimpleInfo roleSimpleInfo,
|
||||
public static async FTask<ChatUnit?> Online(this ChatUnitManageComponent self, Scene scene,
|
||||
RoleSimpleInfo roleSimpleInfo,
|
||||
long gateRouteId)
|
||||
{
|
||||
var accountId = roleSimpleInfo.RoleId;
|
||||
@@ -30,14 +46,22 @@ public static class ChatUnitManageComponentSystem
|
||||
account.GateRouteId = gateRouteId;
|
||||
account.Role = roleSimpleInfo;
|
||||
}
|
||||
|
||||
|
||||
await FTask.CompletedTask;
|
||||
return account;
|
||||
}
|
||||
|
||||
public static async FTask Offline(this ChatUnitManageComponent self, Scene scene, long accountId)
|
||||
public static async FTask Offline(this ChatUnitManageComponent self, Scene scene, long accountId, long gateRouteId)
|
||||
{
|
||||
self.Remove(accountId);
|
||||
if (self.TryGet(accountId, out var unit) && unit != null)
|
||||
{
|
||||
if (unit.GateRouteId == gateRouteId)
|
||||
{
|
||||
Log.Info("退出当前聊天服==");
|
||||
self.Remove(accountId); //如果当前网关和下线的网关一致
|
||||
}
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user