新增私聊相关
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// 请求创建频道
|
||||
/// </summary>
|
||||
public class
|
||||
C2S_CreateChannelRequestHandler : RouteRPC<SocialUnit, C2S_CreateChannelRequest, S2C_CreateChannelResponse>
|
||||
{
|
||||
protected override async FTask Run(SocialUnit entity, C2S_CreateChannelRequest request,
|
||||
S2C_CreateChannelResponse response, Action reply)
|
||||
{
|
||||
var channelCenter = entity.Scene.GetComponent<ChatChannelCenterComponent>();
|
||||
if (channelCenter == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var channel = await channelCenter.Create(entity);
|
||||
|
||||
response.ChannelId = channel.Id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// using Fantasy;
|
||||
// using Fantasy.Async;
|
||||
// using Fantasy.Network.Interface;
|
||||
//
|
||||
// namespace NB.Chat;
|
||||
//
|
||||
// public class
|
||||
// C2S_GetOfflineMessageRequestHandler : RouteRPC<SocialUnit, C2S_GetOfflineMessageRequest,
|
||||
// S2C_GetOfflineMessageResponse>
|
||||
// {
|
||||
// protected override async FTask Run(SocialUnit entity, C2S_GetOfflineMessageRequest request,
|
||||
// S2C_GetOfflineMessageResponse response,
|
||||
// Action reply)
|
||||
// {
|
||||
// var chatUnitManage = entity.Scene.GetComponent<SocialUnitManageComponent>();
|
||||
// if (chatUnitManage.NotSendMessage.TryGetValue(entity.Id, out var list))
|
||||
// {
|
||||
// response.Message.AddRange(list);
|
||||
// chatUnitManage.NotSendMessage.RemoveByKey(entity.Id);
|
||||
// }
|
||||
//
|
||||
// await FTask.CompletedTask;
|
||||
// }
|
||||
// }
|
||||
60
Hotfix/Social/Chat/Handler/C2S_JoinChannelRequestHandler.cs
Normal file
60
Hotfix/Social/Chat/Handler/C2S_JoinChannelRequestHandler.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// 请求进入频道
|
||||
/// </summary>
|
||||
public class
|
||||
C2S_JoinChannelRequestHandler : RouteRPC<SocialUnit, C2S_JoinChannelRequest, S2C_JoinChannelResponse>
|
||||
{
|
||||
protected override async FTask Run(SocialUnit entity, C2S_JoinChannelRequest request,
|
||||
S2C_JoinChannelResponse response, Action reply)
|
||||
{
|
||||
if (request.Target < 1)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
var channelCenter = entity.Scene.GetComponent<ChatChannelCenterComponent>();
|
||||
if (channelCenter == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var oldChannelId = entity.CurrentChannel;
|
||||
if (oldChannelId > 0)
|
||||
{
|
||||
//退出旧的频道
|
||||
var oldChannel = await channelCenter.Get(oldChannelId);
|
||||
if (oldChannel != null)
|
||||
{
|
||||
oldChannel.Exit(entity);
|
||||
}
|
||||
}
|
||||
|
||||
//加入新频道
|
||||
var newChannel = await channelCenter.Get(request.Target);
|
||||
if (newChannel != null)
|
||||
{
|
||||
if (newChannel.ChannelType == 1)
|
||||
{
|
||||
//工会频道需要再工会才能加入
|
||||
}
|
||||
else if (newChannel.ChannelType == 0)
|
||||
{
|
||||
//地图频道需要判断在这个地图才能加入
|
||||
}
|
||||
|
||||
newChannel.Enter(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ChatNotChannel;
|
||||
}
|
||||
}
|
||||
}
|
||||
155
Hotfix/Social/Chat/Handler/C2S_SendMessageRequestHandler.cs
Normal file
155
Hotfix/Social/Chat/Handler/C2S_SendMessageRequestHandler.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Helper;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB.Game;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
public sealed class
|
||||
C2S_SendMessageRequestHandler : RouteRPC<SocialUnit, C2S_SendMessageRequest, S2C_SendMessageResponse>
|
||||
{
|
||||
protected override async FTask Run(SocialUnit socialUnit, C2S_SendMessageRequest request,
|
||||
S2C_SendMessageResponse response, Action reply)
|
||||
{
|
||||
if (request.Target < 1)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
SocialSceneHelper.BroadcastChannel(socialUnit.Scene, request.Target, new ChatMessageInfo()
|
||||
{
|
||||
SendTime = TimeHelper.Now,
|
||||
Content = request.Message,
|
||||
});
|
||||
// if (request.Type == 0) //频道聊天
|
||||
// {
|
||||
// }
|
||||
// else if (request.Type == 1) //私聊
|
||||
// {
|
||||
// //发送私聊
|
||||
// SocialSceneHelper.PrivateMessage(socialUnit.Scene, socialUnit.Id, request.Target, new ChatMessageInfo()
|
||||
// {
|
||||
// SendTime = TimeHelper.Now,
|
||||
// Content = request.Message,
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// var list = new List<long>()
|
||||
// {
|
||||
// 337951357380329472,
|
||||
// 337951357380329473,
|
||||
// 337951357380329474,
|
||||
// 337951357380329475,
|
||||
// 337951357380329476,
|
||||
// 337951357380329477,
|
||||
// 337951357380329478,
|
||||
// 337951357380329479,
|
||||
// 337951357380329480,
|
||||
// 337951357380329481,
|
||||
// 337951357380329482,
|
||||
// 337951357380329483,
|
||||
// 337951357380329484,
|
||||
// 337951357380329485,
|
||||
// 337951357380329486,
|
||||
// 337951357380329487,
|
||||
// 337951357380329488,
|
||||
// 337951357380329489,
|
||||
// 337951357380329490,
|
||||
// 337951357380329491,
|
||||
// 337951357380329492,
|
||||
// 337951357380329493,
|
||||
// 337951357380329494,
|
||||
// 337951357380329495,
|
||||
// 337951357380329496,
|
||||
// 337951357380329497,
|
||||
// 337951357380329498,
|
||||
// 337951357380329499,
|
||||
// 337951357380329500,
|
||||
// 337951357380329501,
|
||||
// 337951357380329502,
|
||||
// 337951357380329503,
|
||||
// 337951357380329504,
|
||||
// 337951357380329505,
|
||||
// 337951357380329506,
|
||||
// 337951357380329507,
|
||||
// 337951357380329508,
|
||||
// 337951357380329509,
|
||||
// 337951357380329510,
|
||||
// 337951357380329511,
|
||||
// 337951357380329512,
|
||||
// 337951357380329513,
|
||||
// 337951357380329514,
|
||||
// 337951357380329515,
|
||||
// 337951357380329516,
|
||||
// 337951357380329517,
|
||||
// 337951357380329518,
|
||||
// 337951357380329519,
|
||||
// 337951357380329520,
|
||||
// 337951357380329521,
|
||||
// 337951357380329522,
|
||||
// 337951357380329523,
|
||||
// 337951357380329524,
|
||||
// 337951357380329525,
|
||||
// 337951357380329526,
|
||||
// 337951357380329527,
|
||||
// 337951357380329528,
|
||||
// 337951357380329529,
|
||||
// 337951357380329530,
|
||||
// 337951357380329531,
|
||||
// 337951357380329532,
|
||||
// 337951357380329533,
|
||||
// 337951357380329534,
|
||||
// 337951357380329535,
|
||||
// 337951357380329536,
|
||||
// 337951357380329537,
|
||||
// 337951357380329538,
|
||||
// 337951357380329539,
|
||||
// 337951357380329540,
|
||||
// 337951357380329541,
|
||||
// 337951357380329542,
|
||||
// 337951357380329543,
|
||||
// 337951357380329544,
|
||||
// 337951357380329545,
|
||||
// 337951357380329546,
|
||||
// 337951357380329547,
|
||||
// 337951357380329548,
|
||||
// 337951357380329549,
|
||||
// 337951357380329550,
|
||||
// 337951357380329551,
|
||||
// 337951357380329552,
|
||||
// 337951357380329553,
|
||||
// 337951357380329554,
|
||||
// 337951357380329555,
|
||||
// 337951357380329556,
|
||||
// 337951357380329557,
|
||||
// 337951357380329558,
|
||||
// 337951357380329559,
|
||||
// 337951357380329560,
|
||||
// 337951357380329561,
|
||||
// 337951357380329562,
|
||||
// 337951357380329563,
|
||||
// 337951357380329564,
|
||||
// 337951357380329565,
|
||||
// 337951357380329566,
|
||||
// 337951357380329567,
|
||||
// 337951357380329568,
|
||||
// 337951357380329569,
|
||||
// 337951357380329570,
|
||||
// 337951357380329571
|
||||
// };
|
||||
//
|
||||
// Stopwatch stopwatch = new Stopwatch();
|
||||
// stopwatch.Start();
|
||||
// var infoList = await CacheHandler.GetPlayerBasicCacheInfos(socialUnit.Scene,list);
|
||||
// stopwatch.Stop();
|
||||
// Log.Info($"查询数量={infoList.Count} 耗时={stopwatch.ElapsedMilliseconds}");
|
||||
//
|
||||
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
22
Hotfix/Social/Chat/Handler/Inner/G2S_EnterRequestHandler.cs
Normal file
22
Hotfix/Social/Chat/Handler/Inner/G2S_EnterRequestHandler.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB.Game;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
public class G2S_EnterRequestHandler : RouteRPC<Scene, G2S_EnterRequest, S2G_EnterResponse>
|
||||
{
|
||||
protected override async FTask Run(Scene scene, G2S_EnterRequest request, S2G_EnterResponse response,
|
||||
Action reply)
|
||||
{
|
||||
var roleId = request.Role.RoleId;
|
||||
Log.Debug($"收到 G2S_EnterRequestHandler {roleId}");
|
||||
|
||||
// 在缓存中检查该账号是否存在
|
||||
var chatUnitManageComponent = scene.GetComponent<SocialUnitManageComponent>();
|
||||
var account = await chatUnitManageComponent.Online(scene, request.Role, request.GateRouteId);
|
||||
|
||||
response.RoleRouteId = account.RuntimeId;
|
||||
}
|
||||
}
|
||||
16
Hotfix/Social/Chat/Handler/Inner/G2S_ExitRequestHandler.cs
Normal file
16
Hotfix/Social/Chat/Handler/Inner/G2S_ExitRequestHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
public class G2S_ExitRequestHandler : RouteRPC<Scene, G2S_ExitRequest, S2G_ExitResponse>
|
||||
{
|
||||
protected override async FTask Run(Scene scene, G2S_ExitRequest request, S2G_ExitResponse response,
|
||||
Action reply)
|
||||
{
|
||||
// 在缓存中检查该账号是否存在
|
||||
var chatUnitManageComponent = scene.GetComponent<SocialUnitManageComponent>();
|
||||
await chatUnitManageComponent.Offline(scene, request.AccountId, request.GateRouteId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user