修改为luban
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// 请求创建频道
|
||||
/// </summary>
|
||||
public class
|
||||
C2S_CreateChannelRequestHandler : AddressRPC<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;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// using Fantasy;
|
||||
// using Fantasy.Async;
|
||||
// using Fantasy.Network.Interface;
|
||||
//
|
||||
// namespace NB.Chat;
|
||||
//
|
||||
// public class
|
||||
// C2S_GetOfflineMessageRequestHandler : AddressRPC<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;
|
||||
// }
|
||||
// }
|
||||
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// 请求进入频道
|
||||
/// </summary>
|
||||
public class
|
||||
C2S_JoinChannelRequestHandler : AddressRPC<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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
using System;
|
||||
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 : AddressRPC<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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// using Fantasy;
|
||||
// using Fantasy.Async;
|
||||
// using Fantasy.Entitas;
|
||||
// using Fantasy.Network.Interface;
|
||||
//
|
||||
// namespace NB.Chat;
|
||||
//
|
||||
// public sealed class G2Chat_LoginRequestHandler : AddressRPC<Scene, G2Chat_LoginRequest, Chat2G_LoginResponse>
|
||||
// {
|
||||
// protected override async FTask Run(Scene scene, G2Chat_LoginRequest request, Chat2G_LoginResponse response, Action reply)
|
||||
// {
|
||||
// var chatUnit = scene.GetComponent<ChatUnitManageComponent>().Add(request.UnitId, request.UserName, request.GateRouteId);
|
||||
// response.ChatRouteId = chatUnit.RunTimeId;
|
||||
// // 这里模拟创建一个频道用于测试用
|
||||
// var chatChannelCenterComponent = scene.GetComponent<ChatChannelCenterComponent>();
|
||||
// var chatChannelComponent = chatChannelCenterComponent.Apply(1);
|
||||
// // 加入到聊天频道
|
||||
// chatChannelComponent.JoinChannel(request.UnitId);
|
||||
// await FTask.CompletedTask;
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,13 @@
|
||||
// using Fantasy.Async;
|
||||
// using Fantasy.Network.Interface;
|
||||
//
|
||||
// namespace NB.Chat;
|
||||
//
|
||||
// public sealed class G2Chat_OfflineRequestHandler : AddressRPC<ChatUnit, G2Chat_OfflineRequest, Chat2G_OfflineResponse>
|
||||
// {
|
||||
// protected override async FTask Run(ChatUnit chatUnit, G2Chat_OfflineRequest request, Chat2G_OfflineResponse response, Action reply)
|
||||
// {
|
||||
// await FTask.CompletedTask;
|
||||
// chatUnit.Scene.GetComponent<ChatUnitManageComponent>().Remove(chatUnit.Id);
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,20 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
public sealed class Other2Chat_ChatMessageHandler : Address<SocialUnit, Other2Chat_ChatMessage>
|
||||
{
|
||||
protected override async FTask Run(SocialUnit chatUnit, Other2Chat_ChatMessage message)
|
||||
{
|
||||
var result = ChatSceneHelper.Distribution(chatUnit, message.ChatInfoTree, false);
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
Log.Warning($"Other2Chat_ChatMessageHandler: Distribution failed, result: {result}");
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
public sealed class C2Chat_SendMessageRequestHandler : AddressRPC<SocialUnit, C2Chat_SendMessageRequest, Chat2C_SendMessageResponse>
|
||||
{
|
||||
protected override async FTask Run(SocialUnit chatUnit, C2Chat_SendMessageRequest request, Chat2C_SendMessageResponse response, Action reply)
|
||||
{
|
||||
response.ErrorCode = ChatSceneHelper.Distribution(chatUnit, request.ChatInfoTree);
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user