大修改

This commit is contained in:
2025-08-14 23:56:51 +08:00
parent 022cc1ac3e
commit d5689258fc
54 changed files with 775 additions and 839 deletions

View File

@@ -3,5 +3,4 @@
&ę" MultiThread* Addressable@<40>VH &ę" MultiThread* Addressable@<40>VH
(ë" MultiThread*Gate2KCP8 ś@ŤVH (ë" MultiThread*Gate2KCP8 ś@ŤVH
ě" MultiThread*Game@—VH ě" MultiThread*Game@—VH
í" MultiThread*Game@ˇVH
î" MultiThread*Chat@«VH î" MultiThread*Chat@«VH

Binary file not shown.

View File

@@ -1 +1 @@
{"WorksheetNames":[-8419147776733210060,-3495952183970875596,1720330851179383898,3730651590607244245],"Tables":{"-3495952183970875596":1753712105933,"-1088042625810372120":1753532052628,"1720330851179383898":1753711757684,"3730651590607244245":1753532052629,"5812538452563588342":1753532052630}} {"WorksheetNames":[-8419147776733210060,-3495952183970875596,1720330851179383898,5812538452563588342],"Tables":{"-3495952183970875596":1755183581501,"-1088042625810372120":1753532052628,"1720330851179383898":1753711757684,"3730651590607244245":1753532052629,"5812538452563588342":1753532052630}}

View File

@@ -3,6 +3,5 @@
{"Id":1002,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Addressable","NetworkProtocol":null,"OuterPort":0,"InnerPort":11011,"SceneType":2}, {"Id":1002,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Addressable","NetworkProtocol":null,"OuterPort":0,"InnerPort":11011,"SceneType":2},
{"Id":1003,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Gate","NetworkProtocol":"KCP","OuterPort":20000,"InnerPort":11021,"SceneType":3}, {"Id":1003,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Gate","NetworkProtocol":"KCP","OuterPort":20000,"InnerPort":11021,"SceneType":3},
{"Id":1004,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Game","NetworkProtocol":null,"OuterPort":0,"InnerPort":11031,"SceneType":4}, {"Id":1004,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Game","NetworkProtocol":null,"OuterPort":0,"InnerPort":11031,"SceneType":4},
{"Id":1005,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Game","NetworkProtocol":null,"OuterPort":0,"InnerPort":11041,"SceneType":4},
{"Id":1006,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Chat","NetworkProtocol":null,"OuterPort":0,"InnerPort":11051,"SceneType":8} {"Id":1006,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Chat","NetworkProtocol":null,"OuterPort":0,"InnerPort":11051,"SceneType":8}
]} ]}

View File

@@ -26,30 +26,30 @@ message Game2G_ExitResponse // IRouteResponse
///通知游戏服角色进入该聊天服 ///通知游戏服角色进入该聊天服
message G2Chat_EnterRequest // IRouteRequest,Chat2G_EnterResponse message G2S_EnterRequest // IRouteRequest,S2G_EnterResponse
{ {
RoleSimpleInfo Role = 1; //角色信息 RoleSimpleInfo Role = 1; //角色信息
int64 GateRouteId = 2;//网关路由地址 int64 GateRouteId = 2;//网关路由地址
} }
message Chat2G_EnterResponse // IRouteResponse message S2G_EnterResponse // IRouteResponse
{ {
int64 RoleRouteId = 1; //角色实体的路由id int64 RoleRouteId = 1; //角色实体的路由id
} }
message G2Chat_ExitRequest // IRouteRequest,Chat2G_ExitResponse message G2S_ExitRequest // IRouteRequest,S2G_ExitResponse
{ {
int64 AccountId = 1; //账号id int64 AccountId = 1; //账号id
int64 GateRouteId = 2;//网关路由地址 int64 GateRouteId = 2;//网关路由地址
} }
message Chat2G_ExitResponse // IRouteResponse message S2G_ExitResponse // IRouteResponse
{ {
} }
message Chat2G_ChatMessage // IRouteMessage message S2G_ChatMessage // IRouteMessage
{ {
ChatMessageInfo Message = 1; //聊天内容 ChatMessageInfo Message = 1; //聊天内容
repeated int64 IdList = 2; // 群发列表 repeated int64 IdList = 2; // 群发列表

View File

@@ -1,98 +0,0 @@
syntax = "proto3";
package Fantasy.Network.Message;
///请求邮件列表
message C2Game_GetMailsRequest // ICustomRouteRequest,Game2C_GetMailsResponse,GameRoute
{
}
///获取邮件列表响应
message Game2C_GetMailsResponse // ICustomRouteResponse
{
repeated MailInfo Mail = 1;
}
///新邮件推送
message Game2C_HaveMail // ICustomRouteMessage,GameRoute
{
MailInfo Mail = 1;
}
message Game2C_MailState // ICustomRouteMessage,GameRoute
{
int32 MailState = 1;
int64 MailId = 2;
}
////////////// ******** 聊天 *******/////////////
///创建频道
message C2Chat_CreateChannelRequest // ICustomRouteRequest,Caht2C_CreateChannelResponse,ChatRoute
{
string Name = 1; //频道名称
}
///创建频道响应
message Caht2C_CreateChannelResponse // ICustomRouteResponse
{
int64 ChannelId = 1; //创建的频道id
}
///请求进入频道
message C2Chat_JoinChannelRequest // ICustomRouteRequest,Caht2C_JoinChannelResponse,ChatRoute
{
int64 Target = 1; // 频道id
}
///进入频道响应
message Caht2C_JoinChannelResponse // ICustomRouteResponse
{
}
///发送聊天
message C2Chat_SendMessageRequest // ICustomRouteRequest,Caht2C_SendMessageResponse,ChatRoute
{
int32 Type = 1; //消息类型 0.频道聊天 1.私聊
string Message = 2;
int64 Target = 3; //目标id频道id或者好友id
}
///发送聊天响应
message Caht2C_SendMessageResponse // ICustomRouteResponse
{
}
///获取离线时的未读私聊
message C2Chat_GetOfflineMessageRequest // ICustomRouteRequest,Caht2C_GetOfflineMessageResponse,ChatRoute
{
}
///发送聊天响应
message Caht2C_GetOfflineMessageResponse // ICustomRouteResponse
{
repeated ChatMessageInfo Message = 1;
}
///推送消息
message Chat2C_Message // ICustomRouteMessage,ChatRoute
{
ChatMessageInfo Message = 1;
}
///获取聊天记录请求
message C2Chat_GetChatRecordRequest // ICustomRouteRequest,Caht2C_GetChatRecordResponse,ChatRoute
{
int64 Target = 1; // 好友id或频道id
int32 Type = 2; // 获取聊天记录类型 0.频道 1.好友
}
///获取聊天记录响应
message Caht2C_GetChatRecordResponse // ICustomRouteResponse
{
repeated ChatMessageInfo Messages = 1; //聊天记录
}

View File

@@ -1,6 +1,122 @@
syntax = "proto3"; syntax = "proto3";
package Fantasy.Network.Message; package Fantasy.Network.Message;
////////////// ******** 邮件 *******/////////////
///请求邮件列表
message C2Game_GetMailsRequest // ICustomRouteRequest,Game2C_GetMailsResponse,GameRoute
{
}
///获取邮件列表响应
message Game2C_GetMailsResponse // ICustomRouteResponse
{
repeated MailInfo Mail = 1;
}
///新邮件推送
message Game2C_HaveMail // ICustomRouteMessage,GameRoute
{
MailInfo Mail = 1;
}
message Game2C_MailState // ICustomRouteMessage,GameRoute
{
int32 MailState = 1;
int64 MailId = 2;
}
////////////// ******** 聊天 *******/////////////
message ChatUserInfo
{
int64 Id = 1;//用户id
int64 Name = 2;//用户名
}
message ChatMessageInfo
{
int32 Type = 1; //消息类型
int64 Source = 2; //消息来源
ChatUserInfo Trigger = 3; //触发者
string Content = 4; //内容
int64 SendTime = 5; //发送时间
}
///创建频道
message C2S_CreateChannelRequest // ICustomRouteRequest,S2C_CreateChannelResponse,SocialRoute
{
string Name = 1; //频道名称
}
///创建频道响应
message S2C_CreateChannelResponse // ICustomRouteResponse
{
int64 ChannelId = 1; //创建的频道id
}
///请求进入频道
message C2S_JoinChannelRequest // ICustomRouteRequest,S2C_JoinChannelResponse,SocialRoute
{
int64 Target = 1; // 频道id
}
///进入频道响应
message S2C_JoinChannelResponse // ICustomRouteResponse
{
}
///发送聊天
message C2S_SendMessageRequest // ICustomRouteRequest,S2C_SendMessageResponse,SocialRoute
{
int32 Type = 1; //消息类型 0.频道聊天 1.私聊
string Message = 2;
int64 Target = 3; //目标id频道id或者好友id
}
///发送聊天响应
message S2C_SendMessageResponse // ICustomRouteResponse
{
}
///发送聊天
message C2S_GetOfflineMessageRequest // ICustomRouteRequest,S2C_GetOfflineMessageResponse,SocialRoute
{
int32 Type = 1; //消息类型 0.频道聊天 1.私聊
string Message = 2;
int64 Target = 3; //目标id频道id或者好友id
}
///发送聊天响应
message S2C_GetOfflineMessageResponse // ICustomRouteResponse
{
repeated ChatMessageInfo Message = 1;
}
///推送消息
message S2C_Message // ICustomRouteMessage,SocialRoute
{
ChatMessageInfo Message = 1;
}
///获取聊天记录请求
message C2S_GetChatRecordRequest // ICustomRouteRequest,S2C_GetChatRecordResponse,SocialRoute
{
int64 Target = 1; // 好友id或频道id
int32 Type = 2; // 获取聊天记录类型 0.频道 1.好友
}
///获取聊天记录响应
message S2C_GetChatRecordResponse // ICustomRouteResponse
{
repeated ChatMessageInfo Messages = 1; //聊天记录
}
message ClubInfo message ClubInfo
{ {
int64 Id = 1; //工会ID int64 Id = 1; //工会ID

View File

@@ -1,14 +0,0 @@
syntax = "proto3";
package Fantasy.Network.Message;
/// 好友信息
message FriendInfo
{
int64 Id = 1; //好友id
int64 AddTime = 2; //添加时间
string NickName = 3; //昵称
string Head = 4; //头像
int32 Level = 5; //等级
string Country = 6; //国家
int32 OnlineStatus = 7; //在线状态
}

View File

@@ -1,16 +0,0 @@
syntax = "proto3";
package Fantasy.Network.Message;
message ChatUserInfo
{
int64 Id = 1;//用户id
int64 Name = 2;//用户名
}
message ChatMessageInfo
{
int32 Type = 1; //消息类型
int64 Source = 2; //消息来源
ChatUserInfo Trigger = 3; //触发者
string Content = 4; //内容
}

View File

@@ -1,5 +1,4 @@
// Route协议定义(需要定义1000以上、因为1000以内的框架预留) // Route协议定义(需要定义1000以上、因为1000以内的框架预留)
GateRoute = 1001 // Gate GateRoute = 1001 // Gate
ChatRoute = 1002 // Chat SocialRoute = 1002 // Social
GameRoute = 1003 // Game GameRoute = 1003 // Game
SocialRoute = 1004 // Social

View File

@@ -28,7 +28,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Game\Friend\" /> <Folder Include="Social\Entity\" />
<Folder Include="Social\Mail\" />
<Folder Include="Generate\NetworkProtocol\" /> <Folder Include="Generate\NetworkProtocol\" />
<Folder Include="Map\" /> <Folder Include="Map\" />
</ItemGroup> </ItemGroup>

View File

@@ -10,7 +10,7 @@ namespace Fantasy
public const int Map = 5; public const int Map = 5;
public const int Activity = 6; public const int Activity = 6;
public const int Cache = 7; public const int Cache = 7;
public const int Chat = 8; public const int Social = 8;
public static readonly Dictionary<string, int> SceneTypeDic = new Dictionary<string, int>() public static readonly Dictionary<string, int> SceneTypeDic = new Dictionary<string, int>()
{ {
@@ -21,7 +21,7 @@ namespace Fantasy
{ "Map", 5 }, { "Map", 5 },
{ "Activity", 6 }, { "Activity", 6 },
{ "Cache", 7 }, { "Cache", 7 },
{ "Chat", 8 }, { "Social", 8 },
}; };
} }
} }

View File

@@ -1,383 +0,0 @@
using ProtoBuf;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using Fantasy;
using Fantasy.Network.Interface;
using Fantasy.Serialize;
// ReSharper disable InconsistentNaming
// ReSharper disable RedundantUsingDirective
// ReSharper disable RedundantOverriddenMember
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable CheckNamespace
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS8618
namespace Fantasy
{
/// <summary>
/// 请求邮件列表
/// </summary>
[ProtoContract]
public partial class C2Game_GetMailsRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Game_GetMailsRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Game_GetMailsRequest>();
}
public override void Dispose()
{
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Game_GetMailsRequest>(this);
#endif
}
[ProtoIgnore]
public Game2C_GetMailsResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Game_GetMailsRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.GameRoute;
}
/// <summary>
/// 获取邮件列表响应
/// </summary>
[ProtoContract]
public partial class Game2C_GetMailsResponse : AMessage, ICustomRouteResponse, IProto
{
public static Game2C_GetMailsResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Game2C_GetMailsResponse>();
}
public override void Dispose()
{
ErrorCode = default;
Mail.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Game2C_GetMailsResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Game2C_GetMailsResponse; }
[ProtoMember(1)]
public List<MailInfo> Mail = new List<MailInfo>();
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 新邮件推送
/// </summary>
[ProtoContract]
public partial class Game2C_HaveMail : AMessage, ICustomRouteMessage, IProto
{
public static Game2C_HaveMail Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Game2C_HaveMail>();
}
public override void Dispose()
{
Mail = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Game2C_HaveMail>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Game2C_HaveMail; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.GameRoute;
[ProtoMember(1)]
public MailInfo Mail { get; set; }
}
[ProtoContract]
public partial class Game2C_MailState : AMessage, ICustomRouteMessage, IProto
{
public static Game2C_MailState Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Game2C_MailState>();
}
public override void Dispose()
{
MailState = default;
MailId = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Game2C_MailState>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Game2C_MailState; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.GameRoute;
[ProtoMember(1)]
public int MailState { get; set; }
[ProtoMember(2)]
public long MailId { get; set; }
}
/// <summary>
/// /////////// ******** 聊天 *******/////////////
/// </summary>
/// <summary>
/// 创建频道
/// </summary>
[ProtoContract]
public partial class C2Chat_CreateChannelRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Chat_CreateChannelRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Chat_CreateChannelRequest>();
}
public override void Dispose()
{
Name = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Chat_CreateChannelRequest>(this);
#endif
}
[ProtoIgnore]
public Caht2C_CreateChannelResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Chat_CreateChannelRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
[ProtoMember(1)]
public string Name { get; set; }
}
/// <summary>
/// 创建频道响应
/// </summary>
[ProtoContract]
public partial class Caht2C_CreateChannelResponse : AMessage, ICustomRouteResponse, IProto
{
public static Caht2C_CreateChannelResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Caht2C_CreateChannelResponse>();
}
public override void Dispose()
{
ErrorCode = default;
ChannelId = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Caht2C_CreateChannelResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Caht2C_CreateChannelResponse; }
[ProtoMember(1)]
public long ChannelId { get; set; }
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 请求进入频道
/// </summary>
[ProtoContract]
public partial class C2Chat_JoinChannelRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Chat_JoinChannelRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Chat_JoinChannelRequest>();
}
public override void Dispose()
{
Target = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Chat_JoinChannelRequest>(this);
#endif
}
[ProtoIgnore]
public Caht2C_JoinChannelResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Chat_JoinChannelRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
[ProtoMember(1)]
public long Target { get; set; }
}
/// <summary>
/// 进入频道响应
/// </summary>
[ProtoContract]
public partial class Caht2C_JoinChannelResponse : AMessage, ICustomRouteResponse, IProto
{
public static Caht2C_JoinChannelResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Caht2C_JoinChannelResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Caht2C_JoinChannelResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Caht2C_JoinChannelResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 发送聊天
/// </summary>
[ProtoContract]
public partial class C2Chat_SendMessageRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Chat_SendMessageRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Chat_SendMessageRequest>();
}
public override void Dispose()
{
Type = default;
Message = default;
Target = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Chat_SendMessageRequest>(this);
#endif
}
[ProtoIgnore]
public Caht2C_SendMessageResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Chat_SendMessageRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public string Message { get; set; }
[ProtoMember(3)]
public long Target { get; set; }
}
/// <summary>
/// 发送聊天响应
/// </summary>
[ProtoContract]
public partial class Caht2C_SendMessageResponse : AMessage, ICustomRouteResponse, IProto
{
public static Caht2C_SendMessageResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Caht2C_SendMessageResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Caht2C_SendMessageResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Caht2C_SendMessageResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 获取离线时的未读私聊
/// </summary>
[ProtoContract]
public partial class C2Chat_GetOfflineMessageRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Chat_GetOfflineMessageRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Chat_GetOfflineMessageRequest>();
}
public override void Dispose()
{
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Chat_GetOfflineMessageRequest>(this);
#endif
}
[ProtoIgnore]
public Caht2C_GetOfflineMessageResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Chat_GetOfflineMessageRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
}
/// <summary>
/// 发送聊天响应
/// </summary>
[ProtoContract]
public partial class Caht2C_GetOfflineMessageResponse : AMessage, ICustomRouteResponse, IProto
{
public static Caht2C_GetOfflineMessageResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Caht2C_GetOfflineMessageResponse>();
}
public override void Dispose()
{
ErrorCode = default;
Message.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Caht2C_GetOfflineMessageResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Caht2C_GetOfflineMessageResponse; }
[ProtoMember(1)]
public List<ChatMessageInfo> Message = new List<ChatMessageInfo>();
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 推送消息
/// </summary>
[ProtoContract]
public partial class Chat2C_Message : AMessage, ICustomRouteMessage, IProto
{
public static Chat2C_Message Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Chat2C_Message>();
}
public override void Dispose()
{
Message = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2C_Message>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Chat2C_Message; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
[ProtoMember(1)]
public ChatMessageInfo Message { get; set; }
}
/// <summary>
/// 获取聊天记录请求
/// </summary>
[ProtoContract]
public partial class C2Chat_GetChatRecordRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Chat_GetChatRecordRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Chat_GetChatRecordRequest>();
}
public override void Dispose()
{
Target = default;
Type = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Chat_GetChatRecordRequest>(this);
#endif
}
[ProtoIgnore]
public Caht2C_GetChatRecordResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Chat_GetChatRecordRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.ChatRoute;
[ProtoMember(1)]
public long Target { get; set; }
[ProtoMember(2)]
public int Type { get; set; }
}
/// <summary>
/// 获取聊天记录响应
/// </summary>
[ProtoContract]
public partial class Caht2C_GetChatRecordResponse : AMessage, ICustomRouteResponse, IProto
{
public static Caht2C_GetChatRecordResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Caht2C_GetChatRecordResponse>();
}
public override void Dispose()
{
ErrorCode = default;
Messages.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Caht2C_GetChatRecordResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Caht2C_GetChatRecordResponse; }
[ProtoMember(1)]
public List<ChatMessageInfo> Messages = new List<ChatMessageInfo>();
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
}

View File

@@ -1,58 +0,0 @@
using ProtoBuf;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using Fantasy;
using Fantasy.Network.Interface;
using Fantasy.Serialize;
// ReSharper disable InconsistentNaming
// ReSharper disable RedundantUsingDirective
// ReSharper disable RedundantOverriddenMember
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable CheckNamespace
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS8618
namespace Fantasy
{
/// <summary>
/// 好友信息
/// </summary>
[ProtoContract]
public partial class FriendInfo : AMessage, IProto
{
public static FriendInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<FriendInfo>();
}
public override void Dispose()
{
Id = default;
AddTime = default;
NickName = default;
Head = default;
Level = default;
Country = default;
OnlineStatus = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<FriendInfo>(this);
#endif
}
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public long AddTime { get; set; }
[ProtoMember(3)]
public string NickName { get; set; }
[ProtoMember(4)]
public string Head { get; set; }
[ProtoMember(5)]
public int Level { get; set; }
[ProtoMember(6)]
public string Country { get; set; }
[ProtoMember(7)]
public int OnlineStatus { get; set; }
}
}

View File

@@ -1,66 +0,0 @@
using ProtoBuf;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using Fantasy;
using Fantasy.Network.Interface;
using Fantasy.Serialize;
// ReSharper disable InconsistentNaming
// ReSharper disable RedundantUsingDirective
// ReSharper disable RedundantOverriddenMember
// ReSharper disable PartialTypeWithSinglePart
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable CheckNamespace
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS8618
namespace Fantasy
{
[ProtoContract]
public partial class ChatUserInfo : AMessage, IProto
{
public static ChatUserInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatUserInfo>();
}
public override void Dispose()
{
Id = default;
Name = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatUserInfo>(this);
#endif
}
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public long Name { get; set; }
}
[ProtoContract]
public partial class ChatMessageInfo : AMessage, IProto
{
public static ChatMessageInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatMessageInfo>();
}
public override void Dispose()
{
Type = default;
Source = default;
Trigger = default;
Content = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatMessageInfo>(this);
#endif
}
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public long Source { get; set; }
[ProtoMember(3)]
public ChatUserInfo Trigger { get; set; }
[ProtoMember(4)]
public string Content { get; set; }
}
}

View File

@@ -112,106 +112,106 @@ namespace Fantasy
/// 通知游戏服角色进入该聊天服 /// 通知游戏服角色进入该聊天服
/// </summary> /// </summary>
[ProtoContract] [ProtoContract]
public partial class G2Chat_EnterRequest : AMessage, IRouteRequest, IProto public partial class G2S_EnterRequest : AMessage, IRouteRequest, IProto
{ {
public static G2Chat_EnterRequest Create(Scene scene) public static G2S_EnterRequest Create(Scene scene)
{ {
return scene.MessagePoolComponent.Rent<G2Chat_EnterRequest>(); return scene.MessagePoolComponent.Rent<G2S_EnterRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
Role = default; Role = default;
GateRouteId = default; GateRouteId = default;
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<G2Chat_EnterRequest>(this); GetScene().MessagePoolComponent.Return<G2S_EnterRequest>(this);
#endif #endif
} }
[ProtoIgnore] [ProtoIgnore]
public Chat2G_EnterResponse ResponseType { get; set; } public S2G_EnterResponse ResponseType { get; set; }
public uint OpCode() { return InnerOpcode.G2Chat_EnterRequest; } public uint OpCode() { return InnerOpcode.G2S_EnterRequest; }
[ProtoMember(1)] [ProtoMember(1)]
public RoleSimpleInfo Role { get; set; } public RoleSimpleInfo Role { get; set; }
[ProtoMember(2)] [ProtoMember(2)]
public long GateRouteId { get; set; } public long GateRouteId { get; set; }
} }
[ProtoContract] [ProtoContract]
public partial class Chat2G_EnterResponse : AMessage, IRouteResponse, IProto public partial class S2G_EnterResponse : AMessage, IRouteResponse, IProto
{ {
public static Chat2G_EnterResponse Create(Scene scene) public static S2G_EnterResponse Create(Scene scene)
{ {
return scene.MessagePoolComponent.Rent<Chat2G_EnterResponse>(); return scene.MessagePoolComponent.Rent<S2G_EnterResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
RoleRouteId = default; RoleRouteId = default;
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2G_EnterResponse>(this); GetScene().MessagePoolComponent.Return<S2G_EnterResponse>(this);
#endif #endif
} }
public uint OpCode() { return InnerOpcode.Chat2G_EnterResponse; } public uint OpCode() { return InnerOpcode.S2G_EnterResponse; }
[ProtoMember(1)] [ProtoMember(1)]
public long RoleRouteId { get; set; } public long RoleRouteId { get; set; }
[ProtoMember(2)] [ProtoMember(2)]
public uint ErrorCode { get; set; } public uint ErrorCode { get; set; }
} }
[ProtoContract] [ProtoContract]
public partial class G2Chat_ExitRequest : AMessage, IRouteRequest, IProto public partial class G2S_ExitRequest : AMessage, IRouteRequest, IProto
{ {
public static G2Chat_ExitRequest Create(Scene scene) public static G2S_ExitRequest Create(Scene scene)
{ {
return scene.MessagePoolComponent.Rent<G2Chat_ExitRequest>(); return scene.MessagePoolComponent.Rent<G2S_ExitRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
AccountId = default; AccountId = default;
GateRouteId = default; GateRouteId = default;
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<G2Chat_ExitRequest>(this); GetScene().MessagePoolComponent.Return<G2S_ExitRequest>(this);
#endif #endif
} }
[ProtoIgnore] [ProtoIgnore]
public Chat2G_ExitResponse ResponseType { get; set; } public S2G_ExitResponse ResponseType { get; set; }
public uint OpCode() { return InnerOpcode.G2Chat_ExitRequest; } public uint OpCode() { return InnerOpcode.G2S_ExitRequest; }
[ProtoMember(1)] [ProtoMember(1)]
public long AccountId { get; set; } public long AccountId { get; set; }
[ProtoMember(2)] [ProtoMember(2)]
public long GateRouteId { get; set; } public long GateRouteId { get; set; }
} }
[ProtoContract] [ProtoContract]
public partial class Chat2G_ExitResponse : AMessage, IRouteResponse, IProto public partial class S2G_ExitResponse : AMessage, IRouteResponse, IProto
{ {
public static Chat2G_ExitResponse Create(Scene scene) public static S2G_ExitResponse Create(Scene scene)
{ {
return scene.MessagePoolComponent.Rent<Chat2G_ExitResponse>(); return scene.MessagePoolComponent.Rent<S2G_ExitResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2G_ExitResponse>(this); GetScene().MessagePoolComponent.Return<S2G_ExitResponse>(this);
#endif #endif
} }
public uint OpCode() { return InnerOpcode.Chat2G_ExitResponse; } public uint OpCode() { return InnerOpcode.S2G_ExitResponse; }
[ProtoMember(1)] [ProtoMember(1)]
public uint ErrorCode { get; set; } public uint ErrorCode { get; set; }
} }
[ProtoContract] [ProtoContract]
public partial class Chat2G_ChatMessage : AMessage, IRouteMessage, IProto public partial class S2G_ChatMessage : AMessage, IRouteMessage, IProto
{ {
public static Chat2G_ChatMessage Create(Scene scene) public static S2G_ChatMessage Create(Scene scene)
{ {
return scene.MessagePoolComponent.Rent<Chat2G_ChatMessage>(); return scene.MessagePoolComponent.Rent<S2G_ChatMessage>();
} }
public override void Dispose() public override void Dispose()
{ {
Message = default; Message = default;
IdList.Clear(); IdList.Clear();
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2G_ChatMessage>(this); GetScene().MessagePoolComponent.Return<S2G_ChatMessage>(this);
#endif #endif
} }
public uint OpCode() { return InnerOpcode.Chat2G_ChatMessage; } public uint OpCode() { return InnerOpcode.S2G_ChatMessage; }
[ProtoMember(1)] [ProtoMember(1)]
public ChatMessageInfo Message { get; set; } public ChatMessageInfo Message { get; set; }
[ProtoMember(2)] [ProtoMember(2)]

View File

@@ -6,11 +6,11 @@ namespace Fantasy
public const uint Game2G_EnterResponse = 1207969553; public const uint Game2G_EnterResponse = 1207969553;
public const uint G2Game_ExitRequest = 1073751826; public const uint G2Game_ExitRequest = 1073751826;
public const uint Game2G_ExitResponse = 1207969554; public const uint Game2G_ExitResponse = 1207969554;
public const uint G2Chat_EnterRequest = 1073751827; public const uint G2S_EnterRequest = 1073751827;
public const uint Chat2G_EnterResponse = 1207969555; public const uint S2G_EnterResponse = 1207969555;
public const uint G2Chat_ExitRequest = 1073751828; public const uint G2S_ExitRequest = 1073751828;
public const uint Chat2G_ExitResponse = 1207969556; public const uint S2G_ExitResponse = 1207969556;
public const uint Chat2G_ChatMessage = 939534097; public const uint S2G_ChatMessage = 939534097;
public const uint Club2Chat_CreateChannel = 939534098; public const uint Club2Chat_CreateChannel = 939534098;
} }
} }

View File

@@ -2,28 +2,28 @@ namespace Fantasy
{ {
public static partial class OuterOpcode public static partial class OuterOpcode
{ {
public const uint C2Game_GetMailsRequest = 2281711377;
public const uint Game2C_GetMailsResponse = 2415929105;
public const uint Game2C_HaveMail = 2147493649;
public const uint Game2C_MailState = 2147493650;
public const uint C2Chat_CreateChannelRequest = 2281711378;
public const uint Caht2C_CreateChannelResponse = 2415929106;
public const uint C2Chat_JoinChannelRequest = 2281711379;
public const uint Caht2C_JoinChannelResponse = 2415929107;
public const uint C2Chat_SendMessageRequest = 2281711380;
public const uint Caht2C_SendMessageResponse = 2415929108;
public const uint C2Chat_GetOfflineMessageRequest = 2281711381;
public const uint Caht2C_GetOfflineMessageResponse = 2415929109;
public const uint Chat2C_Message = 2147493651;
public const uint C2Chat_GetChatRecordRequest = 2281711382;
public const uint Caht2C_GetChatRecordResponse = 2415929110;
public const uint C2A_LoginRequest = 268445457; public const uint C2A_LoginRequest = 268445457;
public const uint A2C_LoginResponse = 402663185; public const uint A2C_LoginResponse = 402663185;
public const uint C2G_LoginRequest = 268445458; public const uint C2G_LoginRequest = 268445458;
public const uint G2C_LoginResponse = 402663186; public const uint G2C_LoginResponse = 402663186;
public const uint G2C_RepeatLogin = 134227729; public const uint G2C_RepeatLogin = 134227729;
public const uint C2Game_GetRoleInfoRequest = 2281711383; public const uint C2Game_GetRoleInfoRequest = 2281711377;
public const uint Game2C_GetRoleInfoResponse = 2415929111; public const uint Game2C_GetRoleInfoResponse = 2415929105;
public const uint C2Game_GetMailsRequest = 2281711378;
public const uint Game2C_GetMailsResponse = 2415929106;
public const uint Game2C_HaveMail = 2147493649;
public const uint Game2C_MailState = 2147493650;
public const uint C2S_CreateChannelRequest = 2281711379;
public const uint S2C_CreateChannelResponse = 2415929107;
public const uint C2S_JoinChannelRequest = 2281711380;
public const uint S2C_JoinChannelResponse = 2415929108;
public const uint C2S_SendMessageRequest = 2281711381;
public const uint S2C_SendMessageResponse = 2415929109;
public const uint C2S_GetOfflineMessageRequest = 2281711382;
public const uint S2C_GetOfflineMessageResponse = 2415929110;
public const uint S2C_Message = 2147493651;
public const uint C2S_GetChatRecordRequest = 2281711383;
public const uint S2C_GetChatRecordResponse = 2415929111;
public const uint C2S_CreateClubRequest = 2281711384; public const uint C2S_CreateClubRequest = 2281711384;
public const uint S2C_CreateClubResponse = 2415929112; public const uint S2C_CreateClubResponse = 2415929112;
public const uint C2S_GetClubInfoRequest = 2281711385; public const uint C2S_GetClubInfoRequest = 2281711385;

View File

@@ -4,8 +4,7 @@ namespace Fantasy
public static class RouteType public static class RouteType
{ {
public const int GateRoute = 1001; // Gate public const int GateRoute = 1001; // Gate
public const int ChatRoute = 1002; // Chat public const int SocialRoute = 1002; // Social
public const int GameRoute = 1003; // Game public const int GameRoute = 1003; // Game
public const int SocialRoute = 1004; // Social
} }
} }

View File

@@ -17,6 +17,430 @@ using Fantasy.Serialize;
namespace Fantasy namespace Fantasy
{ {
/// <summary>
/// /////////// ******** 邮件 *******/////////////
/// </summary>
/// <summary>
/// 请求邮件列表
/// </summary>
[ProtoContract]
public partial class C2Game_GetMailsRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Game_GetMailsRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Game_GetMailsRequest>();
}
public override void Dispose()
{
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Game_GetMailsRequest>(this);
#endif
}
[ProtoIgnore]
public Game2C_GetMailsResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Game_GetMailsRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.GameRoute;
}
/// <summary>
/// 获取邮件列表响应
/// </summary>
[ProtoContract]
public partial class Game2C_GetMailsResponse : AMessage, ICustomRouteResponse, IProto
{
public static Game2C_GetMailsResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Game2C_GetMailsResponse>();
}
public override void Dispose()
{
ErrorCode = default;
Mail.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Game2C_GetMailsResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Game2C_GetMailsResponse; }
[ProtoMember(1)]
public List<MailInfo> Mail = new List<MailInfo>();
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 新邮件推送
/// </summary>
[ProtoContract]
public partial class Game2C_HaveMail : AMessage, ICustomRouteMessage, IProto
{
public static Game2C_HaveMail Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Game2C_HaveMail>();
}
public override void Dispose()
{
Mail = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Game2C_HaveMail>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Game2C_HaveMail; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.GameRoute;
[ProtoMember(1)]
public MailInfo Mail { get; set; }
}
[ProtoContract]
public partial class Game2C_MailState : AMessage, ICustomRouteMessage, IProto
{
public static Game2C_MailState Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Game2C_MailState>();
}
public override void Dispose()
{
MailState = default;
MailId = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Game2C_MailState>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Game2C_MailState; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.GameRoute;
[ProtoMember(1)]
public int MailState { get; set; }
[ProtoMember(2)]
public long MailId { get; set; }
}
/// <summary>
/// /////////// ******** 聊天 *******/////////////
/// </summary>
[ProtoContract]
public partial class ChatUserInfo : AMessage, IProto
{
public static ChatUserInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatUserInfo>();
}
public override void Dispose()
{
Id = default;
Name = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatUserInfo>(this);
#endif
}
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public long Name { get; set; }
}
[ProtoContract]
public partial class ChatMessageInfo : AMessage, IProto
{
public static ChatMessageInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<ChatMessageInfo>();
}
public override void Dispose()
{
Type = default;
Source = default;
Trigger = default;
Content = default;
SendTime = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<ChatMessageInfo>(this);
#endif
}
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public long Source { get; set; }
[ProtoMember(3)]
public ChatUserInfo Trigger { get; set; }
[ProtoMember(4)]
public string Content { get; set; }
[ProtoMember(5)]
public long SendTime { get; set; }
}
/// <summary>
/// 创建频道
/// </summary>
[ProtoContract]
public partial class C2S_CreateChannelRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2S_CreateChannelRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2S_CreateChannelRequest>();
}
public override void Dispose()
{
Name = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2S_CreateChannelRequest>(this);
#endif
}
[ProtoIgnore]
public S2C_CreateChannelResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2S_CreateChannelRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.SocialRoute;
[ProtoMember(1)]
public string Name { get; set; }
}
/// <summary>
/// 创建频道响应
/// </summary>
[ProtoContract]
public partial class S2C_CreateChannelResponse : AMessage, ICustomRouteResponse, IProto
{
public static S2C_CreateChannelResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<S2C_CreateChannelResponse>();
}
public override void Dispose()
{
ErrorCode = default;
ChannelId = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<S2C_CreateChannelResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.S2C_CreateChannelResponse; }
[ProtoMember(1)]
public long ChannelId { get; set; }
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 请求进入频道
/// </summary>
[ProtoContract]
public partial class C2S_JoinChannelRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2S_JoinChannelRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2S_JoinChannelRequest>();
}
public override void Dispose()
{
Target = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2S_JoinChannelRequest>(this);
#endif
}
[ProtoIgnore]
public S2C_JoinChannelResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2S_JoinChannelRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.SocialRoute;
[ProtoMember(1)]
public long Target { get; set; }
}
/// <summary>
/// 进入频道响应
/// </summary>
[ProtoContract]
public partial class S2C_JoinChannelResponse : AMessage, ICustomRouteResponse, IProto
{
public static S2C_JoinChannelResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<S2C_JoinChannelResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<S2C_JoinChannelResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.S2C_JoinChannelResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 发送聊天
/// </summary>
[ProtoContract]
public partial class C2S_SendMessageRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2S_SendMessageRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2S_SendMessageRequest>();
}
public override void Dispose()
{
Type = default;
Message = default;
Target = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2S_SendMessageRequest>(this);
#endif
}
[ProtoIgnore]
public S2C_SendMessageResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2S_SendMessageRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.SocialRoute;
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public string Message { get; set; }
[ProtoMember(3)]
public long Target { get; set; }
}
/// <summary>
/// 发送聊天响应
/// </summary>
[ProtoContract]
public partial class S2C_SendMessageResponse : AMessage, ICustomRouteResponse, IProto
{
public static S2C_SendMessageResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<S2C_SendMessageResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<S2C_SendMessageResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.S2C_SendMessageResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 发送聊天
/// </summary>
[ProtoContract]
public partial class C2S_GetOfflineMessageRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2S_GetOfflineMessageRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2S_GetOfflineMessageRequest>();
}
public override void Dispose()
{
Type = default;
Message = default;
Target = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2S_GetOfflineMessageRequest>(this);
#endif
}
[ProtoIgnore]
public S2C_GetOfflineMessageResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2S_GetOfflineMessageRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.SocialRoute;
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public string Message { get; set; }
[ProtoMember(3)]
public long Target { get; set; }
}
/// <summary>
/// 发送聊天响应
/// </summary>
[ProtoContract]
public partial class S2C_GetOfflineMessageResponse : AMessage, ICustomRouteResponse, IProto
{
public static S2C_GetOfflineMessageResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<S2C_GetOfflineMessageResponse>();
}
public override void Dispose()
{
ErrorCode = default;
Message.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<S2C_GetOfflineMessageResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.S2C_GetOfflineMessageResponse; }
[ProtoMember(1)]
public List<ChatMessageInfo> Message = new List<ChatMessageInfo>();
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
/// <summary>
/// 推送消息
/// </summary>
[ProtoContract]
public partial class S2C_Message : AMessage, ICustomRouteMessage, IProto
{
public static S2C_Message Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<S2C_Message>();
}
public override void Dispose()
{
Message = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<S2C_Message>(this);
#endif
}
public uint OpCode() { return OuterOpcode.S2C_Message; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.SocialRoute;
[ProtoMember(1)]
public ChatMessageInfo Message { get; set; }
}
/// <summary>
/// 获取聊天记录请求
/// </summary>
[ProtoContract]
public partial class C2S_GetChatRecordRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2S_GetChatRecordRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2S_GetChatRecordRequest>();
}
public override void Dispose()
{
Target = default;
Type = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2S_GetChatRecordRequest>(this);
#endif
}
[ProtoIgnore]
public S2C_GetChatRecordResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2S_GetChatRecordRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.SocialRoute;
[ProtoMember(1)]
public long Target { get; set; }
[ProtoMember(2)]
public int Type { get; set; }
}
/// <summary>
/// 获取聊天记录响应
/// </summary>
[ProtoContract]
public partial class S2C_GetChatRecordResponse : AMessage, ICustomRouteResponse, IProto
{
public static S2C_GetChatRecordResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<S2C_GetChatRecordResponse>();
}
public override void Dispose()
{
ErrorCode = default;
Messages.Clear();
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<S2C_GetChatRecordResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.S2C_GetChatRecordResponse; }
[ProtoMember(1)]
public List<ChatMessageInfo> Messages = new List<ChatMessageInfo>();
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class ClubInfo : AMessage, IProto public partial class ClubInfo : AMessage, IProto
{ {

View File

@@ -9,12 +9,12 @@ namespace NB.Chat;
public class ChatChannel : Entity public class ChatChannel : Entity
{ {
/// <summary> /// <summary>
/// 频道id /// 频道绑定id
/// </summary> /// </summary>
[BsonElement("cid")] public uint ChannelId; [BsonElement("cid")] public long ChannelId;
/// <summary> /// <summary>
/// 频道类型 0.地图 1.公开 2.私密 /// 频道类型 0.地图 1.工会频道
/// </summary> /// </summary>
[BsonElement("type")] public uint ChannelType; [BsonElement("type")] public uint ChannelType;

View File

@@ -3,7 +3,7 @@ using Fantasy.Entitas;
namespace NB.Chat; namespace NB.Chat;
public sealed class ChatUnit : Entity public sealed class SocialUnit : Entity
{ {
public long GateRouteId; public long GateRouteId;

View File

@@ -4,14 +4,12 @@ using Fantasy.Entitas;
namespace NB.Chat; namespace NB.Chat;
public class ChatUnitManageComponent : Entity public class SocialUnitManageComponent : Entity
{ {
public readonly Dictionary<long, ChatUnit> ChatUnits = new(); public readonly Dictionary<long, SocialUnit> Units = new();
/// <summary> /// <summary>
/// 不在线消息缓存 /// 不在线消息缓存
/// </summary> /// </summary>
public readonly OneToManyList<long, ChatMessageInfo> NotSendMessage = new(); public readonly OneToManyList<long, ChatMessageInfo> NotSendMessage = new();
public readonly OneToManyList<string, ChatMessageInfo> PrivateMessage = new();
} }

View File

@@ -1,45 +0,0 @@
using System.Text;
using Fantasy;
using Fantasy.Async;
using Fantasy.Network.Interface;
namespace NB.Chat;
public sealed class
C2Chat_SendMessageRequestHandler : RouteRPC<ChatUnit, C2Chat_SendMessageRequest, Caht2C_SendMessageResponse>
{
protected override async FTask Run(ChatUnit chatUnit, C2Chat_SendMessageRequest request,
Caht2C_SendMessageResponse response, Action reply)
{
if (request.Target < 1)
{
response.ErrorCode = ErrorCode.ErrArgs;
return;
}
if (request.Type == 0) //频道聊天
{
ChatSceneHelper.BroadcastChannel(chatUnit.Scene, request.Target, new ChatMessageInfo()
{
Content = request.Message,
});
}
else if (request.Type == 1) //私聊
{
//发送私聊
ChatSceneHelper.PrivateMessage(chatUnit.Scene, chatUnit.Id, request.Target, new ChatMessageInfo()
{
Content = request.Message,
});
}
else if (request.Type == 3) //广播聊天
{
ChatSceneHelper.BroadcastAll(chatUnit.Scene, new ChatMessageInfo()
{
Content = request.Message,
});
}
await FTask.CompletedTask;
}
}

View File

@@ -1,16 +0,0 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network.Interface;
namespace NB.Chat;
public class G2Chat_ExitRequestHandler : RouteRPC<Scene, G2Chat_ExitRequest, Chat2G_ExitResponse>
{
protected override async FTask Run(Scene scene, G2Chat_ExitRequest request, Chat2G_ExitResponse response,
Action reply)
{
// 在缓存中检查该账号是否存在
var chatUnitManageComponent = scene.GetComponent<ChatUnitManageComponent>();
await chatUnitManageComponent.Offline(scene, request.AccountId, request.GateRouteId);
}
}

View File

@@ -105,21 +105,6 @@ public static class PlayerManageComponentSystem
account.Statistics.LoginTime = TimeHelper.Now; account.Statistics.LoginTime = TimeHelper.Now;
if (account.GetComponent<MailComponent>() == null)
{
var mailComponent = await scene.World.DataBase.Query<MailComponent>(account.Id, true);
if (mailComponent == null)
{
//如果没有邮件组件
account.AddComponent<MailComponent>();
}
else
{
account.AddComponent(mailComponent);
}
}
await account.Save(); await account.Save();
return account; return account;

View File

@@ -7,11 +7,11 @@ using Fantasy.PacketParser;
namespace NB.Gate; namespace NB.Gate;
public class Chat2G_ChatMessageHandler : Route<Scene, Chat2G_ChatMessage> public class S2G_ChatMessageHandler : Route<Scene, S2G_ChatMessage>
{ {
protected override async FTask Run(Scene scene, Chat2G_ChatMessage message) protected override async FTask Run(Scene scene, S2G_ChatMessage message)
{ {
var chatMessage = new Chat2C_Message() var chatMessage = new S2C_Message()
{ {
Message = message.Message, Message = message.Message,
}; };

View File

@@ -58,13 +58,13 @@ public static class GateLoginHelper
//安排进入的聊天服 //安排进入的聊天服
var (chatRouteId, sceneRouteId) = var (chatRouteId, sceneRouteId) =
await ChatSceneHelper.Online(session.Scene, roleSimpleInfo, session.RuntimeId); await SocialSceneHelper.Online(session.Scene, roleSimpleInfo, session.RuntimeId);
if (chatRouteId <= 0) if (chatRouteId <= 0)
{ {
return ErrorCode.OnlineSceneFailed; return ErrorCode.OnlineSceneFailed;
} }
routeComponent.AddAddress(RouteType.ChatRoute, chatRouteId); routeComponent.AddAddress(RouteType.SocialRoute, chatRouteId);
gateUnit.ChatSceneRouteId = sceneRouteId; gateUnit.ChatSceneRouteId = sceneRouteId;
Log.Info($"连接聊天服成功gameRouteId:{gameRouteId}"); Log.Info($"连接聊天服成功gameRouteId:{gameRouteId}");
return ErrorCode.Successful; return ErrorCode.Successful;
@@ -84,7 +84,7 @@ public static class GateLoginHelper
//通知服务器下线 //通知服务器下线
Log.Info($"断线的session id={sessionId} ChatSceneRouteId={gateUnit.ChatSceneRouteId}"); Log.Info($"断线的session id={sessionId} ChatSceneRouteId={gateUnit.ChatSceneRouteId}");
await GameSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId); await GameSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId);
await ChatSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId, await SocialSceneHelper.Offline(gateUnit.Scene, gateUnit.AccountID, sessionId,
gateUnit.ChatSceneRouteId); gateUnit.ChatSceneRouteId);
return ErrorCode.Successful; return ErrorCode.Successful;
} }

View File

@@ -67,7 +67,7 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem<OnCreateScene>
Log.Debug($"Map Scene SceneRuntimeId:{scene.RuntimeId}"); Log.Debug($"Map Scene SceneRuntimeId:{scene.RuntimeId}");
break; break;
} }
case SceneType.Chat: case SceneType.Social:
{ {
break; break;
} }

View File

@@ -38,10 +38,10 @@ public class OnSceneCreate_Init : AsyncEventSystem<OnCreateScene>
scene.AddComponent<PlayerManageComponent>(); scene.AddComponent<PlayerManageComponent>();
break; break;
} }
case SceneType.Chat: case SceneType.Social:
{ {
//用于管理玩家的组件 //用于管理玩家的组件
scene.AddComponent<ChatUnitManageComponent>(); scene.AddComponent<SocialUnitManageComponent>();
scene.AddComponent<ChatChannelCenterComponent>(); scene.AddComponent<ChatChannelCenterComponent>();
break; break;
} }

View File

@@ -8,10 +8,10 @@ namespace NB.Chat;
/// 请求创建频道 /// 请求创建频道
/// </summary> /// </summary>
public class public class
C2Chat_CreateChannelRequestHandler : RouteRPC<ChatUnit, C2Chat_CreateChannelRequest, Caht2C_CreateChannelResponse> C2S_CreateChannelRequestHandler : RouteRPC<SocialUnit, C2S_CreateChannelRequest, S2C_CreateChannelResponse>
{ {
protected override async FTask Run(ChatUnit entity, C2Chat_CreateChannelRequest request, protected override async FTask Run(SocialUnit entity, C2S_CreateChannelRequest request,
Caht2C_CreateChannelResponse response, Action reply) S2C_CreateChannelResponse response, Action reply)
{ {
var channelCenter = entity.Scene.GetComponent<ChatChannelCenterComponent>(); var channelCenter = entity.Scene.GetComponent<ChatChannelCenterComponent>();
if (channelCenter == null) if (channelCenter == null)

View File

@@ -5,14 +5,14 @@ using Fantasy.Network.Interface;
namespace NB.Chat; namespace NB.Chat;
public class public class
C2Chat_GetOfflineMessageRequestHandler : RouteRPC<ChatUnit, C2Chat_GetOfflineMessageRequest, C2S_GetOfflineMessageRequestHandler : RouteRPC<SocialUnit, C2S_GetOfflineMessageRequest,
Caht2C_GetOfflineMessageResponse> S2C_GetOfflineMessageResponse>
{ {
protected override async FTask Run(ChatUnit entity, C2Chat_GetOfflineMessageRequest request, protected override async FTask Run(SocialUnit entity, C2S_GetOfflineMessageRequest request,
Caht2C_GetOfflineMessageResponse response, S2C_GetOfflineMessageResponse response,
Action reply) Action reply)
{ {
var chatUnitManage = entity.Scene.GetComponent<ChatUnitManageComponent>(); var chatUnitManage = entity.Scene.GetComponent<SocialUnitManageComponent>();
if (chatUnitManage.NotSendMessage.TryGetValue(entity.Id, out var list)) if (chatUnitManage.NotSendMessage.TryGetValue(entity.Id, out var list))
{ {
response.Message.AddRange(list); response.Message.AddRange(list);

View File

@@ -8,16 +8,17 @@ namespace NB.Chat;
/// 请求进入频道 /// 请求进入频道
/// </summary> /// </summary>
public class public class
C2Chat_JoinChannelRequestHandler : RouteRPC<ChatUnit, C2Chat_JoinChannelRequest, Caht2C_JoinChannelResponse> C2S_JoinChannelRequestHandler : RouteRPC<SocialUnit, C2S_JoinChannelRequest, S2C_JoinChannelResponse>
{ {
protected override async FTask Run(ChatUnit entity, C2Chat_JoinChannelRequest request, protected override async FTask Run(SocialUnit entity, C2S_JoinChannelRequest request,
Caht2C_JoinChannelResponse response, Action reply) S2C_JoinChannelResponse response, Action reply)
{ {
if (request.Target < 1) if (request.Target < 1)
{ {
response.ErrorCode = ErrorCode.ErrArgs; response.ErrorCode = ErrorCode.ErrArgs;
return; return;
} }
var channelCenter = entity.Scene.GetComponent<ChatChannelCenterComponent>(); var channelCenter = entity.Scene.GetComponent<ChatChannelCenterComponent>();
if (channelCenter == null) if (channelCenter == null)
{ {
@@ -40,6 +41,15 @@ public class
var newChannel = await channelCenter.Get(request.Target); var newChannel = await channelCenter.Get(request.Target);
if (newChannel != null) if (newChannel != null)
{ {
if (newChannel.ChannelType == 1)
{
//工会频道需要再工会才能加入
}
else if (newChannel.ChannelType == 0)
{
//地图频道需要判断在这个地图才能加入
}
newChannel.Enter(entity); newChannel.Enter(entity);
} }
else else

View File

@@ -0,0 +1,41 @@
using System.Text;
using Fantasy;
using Fantasy.Async;
using Fantasy.Helper;
using Fantasy.Network.Interface;
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;
}
if (request.Type == 0) //频道聊天
{
SocialSceneHelper.BroadcastChannel(socialUnit.Scene, request.Target, new ChatMessageInfo()
{
SendTime = TimeHelper.Now,
Content = request.Message,
});
}
else if (request.Type == 1) //私聊
{
//发送私聊
SocialSceneHelper.PrivateMessage(socialUnit.Scene, socialUnit.Id, request.Target, new ChatMessageInfo()
{
SendTime = TimeHelper.Now,
Content = request.Message,
});
}
await FTask.CompletedTask;
}
}

View File

@@ -5,16 +5,16 @@ using NB.Game;
namespace NB.Chat; namespace NB.Chat;
public class G2Chat_EnterRequestHandler : RouteRPC<Scene, G2Chat_EnterRequest, Chat2G_EnterResponse> public class G2S_EnterRequestHandler : RouteRPC<Scene, G2S_EnterRequest, S2G_EnterResponse>
{ {
protected override async FTask Run(Scene scene, G2Chat_EnterRequest request, Chat2G_EnterResponse response, protected override async FTask Run(Scene scene, G2S_EnterRequest request, S2G_EnterResponse response,
Action reply) Action reply)
{ {
var roleId = request.Role.RoleId; var roleId = request.Role.RoleId;
Log.Debug($"收到 G2Chat_EnterRequestHandler {roleId}"); Log.Debug($"收到 G2S_EnterRequestHandler {roleId}");
// 在缓存中检查该账号是否存在 // 在缓存中检查该账号是否存在
var chatUnitManageComponent = scene.GetComponent<ChatUnitManageComponent>(); var chatUnitManageComponent = scene.GetComponent<SocialUnitManageComponent>();
var account = await chatUnitManageComponent.Online(scene, request.Role, request.GateRouteId); var account = await chatUnitManageComponent.Online(scene, request.Role, request.GateRouteId);
response.RoleRouteId = account.RuntimeId; response.RoleRouteId = account.RuntimeId;

View 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);
}
}

View File

@@ -12,9 +12,9 @@ public static class ChatUnitFactory
/// <param name="aId">ToKen令牌传递过来的aId</param> /// <param name="aId">ToKen令牌传递过来的aId</param>
/// <param name="isSaveDataBase">是否在创建的过程中保存到数据库</param> /// <param name="isSaveDataBase">是否在创建的过程中保存到数据库</param>
/// <returns></returns> /// <returns></returns>
public static ChatUnit Create(Scene scene, long aId) public static SocialUnit Create(Scene scene, long aId)
{ {
var player = Entity.Create<ChatUnit>(scene, aId, true, true); var player = Entity.Create<SocialUnit>(scene, aId, true, true);
return player; return player;
} }
} }

View File

@@ -4,7 +4,7 @@ using Fantasy.Platform.Net;
namespace NB.Chat; namespace NB.Chat;
public static class ChatSceneHelper public static class SocialSceneHelper
{ {
#region #region
@@ -17,7 +17,7 @@ public static class ChatSceneHelper
/// <param name="message"></param> /// <param name="message"></param>
public static void PrivateMessage(Scene scene, long selfId, long targetId, ChatMessageInfo message) public static void PrivateMessage(Scene scene, long selfId, long targetId, ChatMessageInfo message)
{ {
var chatUnitManage = scene.GetComponent<ChatUnitManageComponent>(); var chatUnitManage = scene.GetComponent<SocialUnitManageComponent>();
if (chatUnitManage == null) return; if (chatUnitManage == null) return;
var chatUnit = chatUnitManage.Get(targetId); var chatUnit = chatUnitManage.Get(targetId);
message.Type = 1; message.Type = 1;
@@ -42,10 +42,10 @@ public static class ChatSceneHelper
/// <param name="message"></param> /// <param name="message"></param>
public static void BroadcastMap(Scene scene, long mapId, ChatMessageInfo message) public static void BroadcastMap(Scene scene, long mapId, ChatMessageInfo message)
{ {
var chatUnitManage = scene.GetComponent<ChatUnitManageComponent>(); var chatUnitManage = scene.GetComponent<SocialUnitManageComponent>();
if (chatUnitManage == null) return; if (chatUnitManage == null) return;
HashSet<long> targets = new HashSet<long>(); HashSet<long> targets = new HashSet<long>();
foreach (var (_, chatUnit) in chatUnitManage.ChatUnits) foreach (var (_, chatUnit) in chatUnitManage.Units)
{ {
if (chatUnit.MapId == mapId) if (chatUnit.MapId == mapId)
{ {
@@ -70,10 +70,10 @@ public static class ChatSceneHelper
/// <param name="message"></param> /// <param name="message"></param>
public static void BroadcastChannel(Scene scene, long channelId, ChatMessageInfo message) public static void BroadcastChannel(Scene scene, long channelId, ChatMessageInfo message)
{ {
var chatUnitManage = scene.GetComponent<ChatUnitManageComponent>(); var chatUnitManage = scene.GetComponent<SocialUnitManageComponent>();
if (chatUnitManage == null) return; if (chatUnitManage == null) return;
HashSet<long> targets = new HashSet<long>(); HashSet<long> targets = new HashSet<long>();
foreach (var (_, chatUnit) in chatUnitManage.ChatUnits) foreach (var (_, chatUnit) in chatUnitManage.Units)
{ {
if (chatUnit.CurrentChannel == channelId) if (chatUnit.CurrentChannel == channelId)
{ {
@@ -100,7 +100,7 @@ public static class ChatSceneHelper
{ {
//发送给所有Gate服务器让Gate转发给其他客户端 //发送给所有Gate服务器让Gate转发给其他客户端
var gateConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate); var gateConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate);
var sendMessage = new Chat2G_ChatMessage() var sendMessage = new S2G_ChatMessage()
{ {
Message = message, Message = message,
}; };
@@ -127,8 +127,8 @@ public static class ChatSceneHelper
var gameSceneConfig = GetSceneConfig(); var gameSceneConfig = GetSceneConfig();
var gameRouteId = gameSceneConfig.RouteId; var gameRouteId = gameSceneConfig.RouteId;
//连接到游戏中心服 //连接到游戏中心服
var gameResponse = (Chat2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute( var gameResponse = (S2G_EnterResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
gameRouteId, new G2Chat_EnterRequest() gameRouteId, new G2S_EnterRequest()
{ {
Role = roleSimple, Role = roleSimple,
GateRouteId = gateRuntimeId GateRouteId = gateRuntimeId
@@ -147,8 +147,8 @@ public static class ChatSceneHelper
{ {
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
var gameResponse = (Chat2G_ExitResponse)await scene.NetworkMessagingComponent.CallInnerRoute( var gameResponse = (S2G_ExitResponse)await scene.NetworkMessagingComponent.CallInnerRoute(
sceneRouteId, new G2Chat_ExitRequest() sceneRouteId, new G2S_ExitRequest()
{ {
AccountId = accountId, AccountId = accountId,
GateRouteId = gateRuntimeId GateRouteId = gateRuntimeId
@@ -164,7 +164,7 @@ public static class ChatSceneHelper
private static SceneConfig GetSceneConfig() private static SceneConfig GetSceneConfig()
{ {
var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Chat); var gameSceneConfigs = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Social);
return gameSceneConfigs.First(); return gameSceneConfigs.First();
} }

View File

@@ -51,7 +51,7 @@ public static class ChatChannelCenterComponentSystem
/// <param name="self"></param> /// <param name="self"></param>
/// <param name="unit"></param> /// <param name="unit"></param>
/// <returns></returns> /// <returns></returns>
public static async FTask<ChatChannel> Create(this ChatChannelCenterComponent self, ChatUnit unit) public static async FTask<ChatChannel> Create(this ChatChannelCenterComponent self, SocialUnit unit)
{ {
var channel = Entity.Create<ChatChannel>(self.Scene, true, true); var channel = Entity.Create<ChatChannel>(self.Scene, true, true);
channel.Creator = unit.Role.RoleId; channel.Creator = unit.Role.RoleId;

View File

@@ -1,4 +1,6 @@
namespace NB.Chat; using Fantasy;
namespace NB.Chat;
public static class ChatChannelSystem public static class ChatChannelSystem
{ {
@@ -7,7 +9,7 @@ public static class ChatChannelSystem
/// </summary> /// </summary>
/// <param name="channel"></param> /// <param name="channel"></param>
/// <param name="unit"></param> /// <param name="unit"></param>
public static void Enter(this ChatChannel channel, ChatUnit unit) public static void Enter(this ChatChannel channel, SocialUnit unit)
{ {
channel.Units.Add(unit.Id); channel.Units.Add(unit.Id);
unit.CurrentChannel = channel.Id; unit.CurrentChannel = channel.Id;
@@ -18,7 +20,7 @@ public static class ChatChannelSystem
/// </summary> /// </summary>
/// <param name="channel"></param> /// <param name="channel"></param>
/// <param name="unit"></param> /// <param name="unit"></param>
public static void Exit(this ChatChannel channel, ChatUnit unit) public static void Exit(this ChatChannel channel, SocialUnit unit)
{ {
channel.Units.Remove(unit.Id); channel.Units.Remove(unit.Id);
unit.CurrentChannel = 0; unit.CurrentChannel = 0;

View File

@@ -1,5 +1,6 @@
using Fantasy; using Fantasy;
using Fantasy.Async; using Fantasy.Async;
using Fantasy.Entitas;
using NB.Game; using NB.Game;
namespace NB.Chat; namespace NB.Chat;
@@ -14,11 +15,11 @@ public static class ChatUnitManageComponentSystem
/// <param name="self"></param> /// <param name="self"></param>
/// <param name="targetId"></param> /// <param name="targetId"></param>
/// <param name="message"></param> /// <param name="message"></param>
public static void SaveOfflineMessage(this ChatUnitManageComponent self, long targetId, ChatMessageInfo message) public static void SaveOfflineMessage(this SocialUnitManageComponent self, long targetId, ChatMessageInfo message)
{ {
self.NotSendMessage.Add(targetId, message); self.NotSendMessage.Add(targetId, message);
} }
#endregion #endregion
#region 线线 #region 线线
@@ -30,7 +31,7 @@ public static class ChatUnitManageComponentSystem
/// <param name="scene"></param> /// <param name="scene"></param>
/// <param name="roleSimpleInfo"></param> /// <param name="roleSimpleInfo"></param>
/// <param name="gateRouteId"></param> /// <param name="gateRouteId"></param>
public static async FTask<ChatUnit?> Online(this ChatUnitManageComponent self, Scene scene, public static async FTask<SocialUnit?> Online(this SocialUnitManageComponent self, Scene scene,
RoleSimpleInfo roleSimpleInfo, RoleSimpleInfo roleSimpleInfo,
long gateRouteId) long gateRouteId)
{ {
@@ -43,6 +44,7 @@ public static class ChatUnitManageComponentSystem
if (account != null) if (account != null)
{ {
await account.TryComponent<MailComponent>();
account.GateRouteId = gateRouteId; account.GateRouteId = gateRouteId;
account.Role = roleSimpleInfo; account.Role = roleSimpleInfo;
} }
@@ -51,7 +53,7 @@ public static class ChatUnitManageComponentSystem
return account; return account;
} }
public static async FTask Offline(this ChatUnitManageComponent self, Scene scene, long accountId, long gateRouteId) public static async FTask Offline(this SocialUnitManageComponent self, Scene scene, long accountId, long gateRouteId)
{ {
if (self.TryGet(accountId, out var unit) && unit != null) if (self.TryGet(accountId, out var unit) && unit != null)
{ {
@@ -69,24 +71,24 @@ public static class ChatUnitManageComponentSystem
#region & #region &
public static void Add(this ChatUnitManageComponent self, ChatUnit account) public static void Add(this SocialUnitManageComponent self, SocialUnit account)
{ {
self.ChatUnits.Add(account.Id, account); self.Units.Add(account.Id, account);
} }
public static ChatUnit? Get(this ChatUnitManageComponent self, long accountId) public static SocialUnit? Get(this SocialUnitManageComponent self, long accountId)
{ {
return self.ChatUnits.GetValueOrDefault(accountId); return self.Units.GetValueOrDefault(accountId);
} }
public static bool TryGet(this ChatUnitManageComponent self, long accountId, out ChatUnit? account) public static bool TryGet(this SocialUnitManageComponent self, long accountId, out SocialUnit? account)
{ {
return self.ChatUnits.TryGetValue(accountId, out account); return self.Units.TryGetValue(accountId, out account);
} }
public static void Remove(this ChatUnitManageComponent self, long accountId, bool isDispose = true) public static void Remove(this SocialUnitManageComponent self, long accountId, bool isDispose = true)
{ {
if (!self.ChatUnits.Remove(accountId, out var account)) if (!self.Units.Remove(accountId, out var account))
{ {
return; return;
} }
@@ -100,4 +102,30 @@ public static class ChatUnitManageComponentSystem
} }
#endregion #endregion
#region
/// <summary>
/// 尝试给增加相关组件
/// </summary>
/// <param name="socialUnit"></param>
/// <typeparam name="T"></typeparam>
public static async FTask TryComponent<T>(this SocialUnit socialUnit) where T : Entity, new()
{
if (socialUnit.GetComponent<T>() == null)
{
var mailComponent = await socialUnit.Scene.World.DataBase.Query<T>(socialUnit.Id, true);
if (mailComponent == null)
{
//如果没有邮件组件
socialUnit.AddComponent<T>();
}
else
{
socialUnit.AddComponent(mailComponent);
}
}
}
#endregion
} }

View File

@@ -0,0 +1,11 @@
using Fantasy.Entitas.Interface;
namespace NB.Chat;
public class ChatUnitSystem : AwakeSystem<SocialUnit>
{
protected override void Awake(SocialUnit self)
{
}
}

View File

@@ -0,0 +1 @@
{"ResponseType":null,"RouteType":1002,"Name":"34535"}

View File

@@ -0,0 +1 @@
{"ResponseType":null,"RouteType":1002,"Target":334918114171158528}

View File

@@ -0,0 +1 @@
{"ResponseType":null,"RouteType":1002,"Type":1,"Message":"\u90FD\u662F\u6CD5\u5E08\u6253\u53D1\u65AF\u8482\u82AC\u6492\u61C2\u6CD5\u5B88\u6CD53434","Target":323063059205849090}

View File

@@ -1 +1 @@
{"ResponseType":null,"RouteType":1002,"Type":0,"Message":"\u554A\u6536\u5230\u53D1\u65AF\u8482\u82AC334","Target":323063059205849090} {"ResponseType":null,"RouteType":1002,"Type":1,"Message":"\u554A\u6536\u5230\u53D1\u65AF\u8482\u82AC334","Target":324468767642091522}

View File

@@ -0,0 +1 @@
{"ResponseType":null,"RouteType":1002,"Target":334918114171158528}