chat
This commit is contained in:
@@ -6,6 +6,7 @@ public sealed class Account : Entity
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public int Region { get; set; }
|
||||
public long CreateTime { get; set; }
|
||||
public long LoginTime { get; set; }
|
||||
}
|
||||
29
Entity/Def/RegionDef.cs
Normal file
29
Entity/Def/RegionDef.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace NB;
|
||||
|
||||
public static class RegionDef
|
||||
{
|
||||
/// <summary>
|
||||
/// 中国区
|
||||
/// </summary>
|
||||
public const int CN = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 亚太区
|
||||
/// </summary>
|
||||
public const int Asia = 2;
|
||||
|
||||
/// <summary>
|
||||
/// 欧洲区
|
||||
/// </summary>
|
||||
public const int Europe = 3;
|
||||
|
||||
/// <summary>
|
||||
/// 美洲区
|
||||
/// </summary>
|
||||
public const int America = 4;
|
||||
|
||||
/// <summary>
|
||||
/// 独联体区
|
||||
/// </summary>
|
||||
public const int CIS = 5;
|
||||
}
|
||||
@@ -12,9 +12,4 @@ public sealed class PlayerManageComponent : Entity
|
||||
public long AutoSaveTimerId;
|
||||
|
||||
public readonly Dictionary<long, Player> Players = new();
|
||||
|
||||
/// <summary>
|
||||
/// 需要保存到数据库的玩家
|
||||
/// </summary>
|
||||
public readonly HashSet<long> NeedSavePlayer = new();
|
||||
}
|
||||
14
Entity/Gate/GateUnit.cs
Normal file
14
Entity/Gate/GateUnit.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Network;
|
||||
|
||||
namespace NB.Gate;
|
||||
|
||||
public class GateUnit : Entity
|
||||
{
|
||||
public bool Kick;
|
||||
public long AccountID;
|
||||
public int Region;
|
||||
public long GameSceneRouteId;
|
||||
public long ChatSceneRouteId;
|
||||
public EntityReference<Session> Session;
|
||||
}
|
||||
9
Entity/Gate/GateUnitManageComponent.cs
Normal file
9
Entity/Gate/GateUnitManageComponent.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Network;
|
||||
|
||||
namespace NB.Gate;
|
||||
|
||||
public class GateUnitManageComponent : Entity
|
||||
{
|
||||
public readonly Dictionary<long, GateUnit> Units = new();
|
||||
}
|
||||
8
Entity/Gate/GateUnitSessionComponent.cs
Normal file
8
Entity/Gate/GateUnitSessionComponent.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Gate;
|
||||
|
||||
public sealed class GateUnitSessionComponent : Entity
|
||||
{
|
||||
public long AccountID;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Gate;
|
||||
|
||||
public sealed class SessionPlayerComponent : Entity
|
||||
{
|
||||
public bool Kick { get; set; }
|
||||
|
||||
public long AccountID;
|
||||
}
|
||||
@@ -29,6 +29,7 @@ namespace Fantasy
|
||||
Username = default;
|
||||
Password = default;
|
||||
LoginType = default;
|
||||
Region = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2A_LoginRequest>(this);
|
||||
#endif
|
||||
@@ -42,6 +43,8 @@ namespace Fantasy
|
||||
public string Password { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public int LoginType { get; set; }
|
||||
[ProtoMember(4)]
|
||||
public int Region { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class A2C_LoginResponse : AMessage, IResponse, IProto
|
||||
@@ -284,4 +287,73 @@ namespace Fantasy
|
||||
[ProtoMember(2)]
|
||||
public long MailId { 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()
|
||||
{
|
||||
Message = 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 string Message { 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 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 string Message { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,8 @@ namespace Fantasy
|
||||
public const uint Game2C_GetMailsResponse = 2415929106;
|
||||
public const uint Game2C_HaveMail = 2147493649;
|
||||
public const uint Game2C_MailState = 2147493650;
|
||||
public const uint C2Chat_SendMessageRequest = 2281711379;
|
||||
public const uint Caht2C_SendMessageResponse = 2415929107;
|
||||
public const uint Chat2C_Message = 2147493651;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,11 @@ public class ErrorCode
|
||||
{
|
||||
public const uint Successful = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 服务器上线失败
|
||||
/// </summary>
|
||||
public const uint OnlineSceneFailed = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 参数有误
|
||||
/// </summary>
|
||||
@@ -29,4 +34,9 @@ public class ErrorCode
|
||||
/// 账号或密码有误
|
||||
/// </summary>
|
||||
public const uint ErrAccountOrPass = 11002;
|
||||
|
||||
/// <summary>
|
||||
/// 登录自动注册没有设置地区
|
||||
/// </summary>
|
||||
public const uint RegisterNotRegion = 11011;
|
||||
}
|
||||
Reference in New Issue
Block a user