聊天频道
This commit is contained in:
11
Entity/Chat/ChatChannelCenterComponent.cs
Normal file
11
Entity/Chat/ChatChannelCenterComponent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// 聊天频道管理
|
||||
/// </summary>
|
||||
public class ChatChannelCenterComponent : Entity
|
||||
{
|
||||
public readonly Dictionary<long, ChatChannelComponent> Channels = new Dictionary<long, ChatChannelComponent>();
|
||||
}
|
||||
11
Entity/Chat/ChatChannelComponent.cs
Normal file
11
Entity/Chat/ChatChannelComponent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// 聊天频道实体
|
||||
/// </summary>
|
||||
public class ChatChannelComponent : Entity
|
||||
{
|
||||
public readonly HashSet<long> Units = new HashSet<long>();
|
||||
}
|
||||
@@ -17,4 +17,47 @@ using Fantasy.Serialize;
|
||||
|
||||
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;
|
||||
Trigger = default;
|
||||
Content.Clear();
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<ChatMessageInfo>(this);
|
||||
#endif
|
||||
}
|
||||
[ProtoMember(1)]
|
||||
public int Type { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public ChatUserInfo Trigger { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public List<string> Content = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,9 @@ namespace Fantasy
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
Type = default;
|
||||
Message = default;
|
||||
Target = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2Chat_SendMessageRequest>(this);
|
||||
#endif
|
||||
@@ -310,7 +312,11 @@ namespace Fantasy
|
||||
[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>
|
||||
/// 发送聊天响应
|
||||
@@ -354,6 +360,6 @@ namespace Fantasy
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.ChatRoute;
|
||||
[ProtoMember(1)]
|
||||
public string Message { get; set; }
|
||||
public ChatMessageInfo Message { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user