[+] 接入ET8服务端

[+] 接入ET8服务端
This commit is contained in:
ALEXTANG
2023-07-13 12:23:48 +08:00
parent e0be062006
commit 336d4b2eb9
1316 changed files with 130657 additions and 626 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5ee927a146d81a54bb25900fd6369ae7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8bb8d5a886dd1414681f7574206daa45
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class BenchmarkClientComponent: Entity, IAwake
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c68c60b0718e272488136d3e3e0672ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class BenchmarkServerComponent: Entity, IAwake
{
public int Count { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: adb7fe671c497d6478e3ed62cbee9fe3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 06f629321c0b3d44b9e0606d2b5f5303
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
namespace ET.Server
{
[ComponentOf(typeof(Player))]
public class GateMapComponent: Entity, IAwake
{
private EntityRef<Scene> scene;
public Scene Scene
{
get
{
return this.scene;
}
set
{
this.scene = value;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d6e8828a2661073409b89add293b3508
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class GateSessionKeyComponent : Entity, IAwake
{
public readonly Dictionary<long, string> sessionKey = new();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c4855591c919784c9e72d7ab5414b21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
namespace ET.Server
{
[ChildOf(typeof(PlayerComponent))]
public sealed class Player : Entity, IAwake<string>
{
public string Account { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 98e58bdf33de9a645ab818ae062dca38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Linq;
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class PlayerComponent : Entity, IAwake, IDestroy
{
public Dictionary<string, Player> dictionary = new Dictionary<string, Player>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 639fcaa2e756a964a9556cadc1c5cb5f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
namespace ET.Server
{
[ComponentOf(typeof(Player))]
public class PlayerSessionComponent : Entity, IAwake
{
private EntityRef<Session> session;
public Session Session
{
get
{
return this.session;
}
set
{
this.session = value;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 237648d5968a24ebb885807879f8382d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
namespace ET.Server
{
[ComponentOf(typeof(Session))]
public class SessionPlayerComponent : Entity, IAwake, IDestroy
{
private EntityRef<Player> player;
public Player Player
{
get
{
return this.player;
}
set
{
this.player = value;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: edd141e260773de498ca22f7b9ff072a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a5a2e1e003bdaf4499b66b5d7466a998
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 74ee26df1c91d9d4caac1d4e1c104b90
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 82470970474f53a4a909d6229304bf1f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e2a25a771a90c4a8680f28e4f53a36a4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
namespace ET
{
public struct RobotCase_SecondCaseWait: IWaitType
{
public int Error { get; set; }
public M2C_TestRobotCase2 M2CTestRobotCase2;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba892700102f7430f8c84b01c85721fc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e455bcec0e656e846a5de3abb1dee497
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using CommandLine;
namespace ET.Server
{
public class CreateRobotArgs
{
[Option("Num", Required = false, Default = 1)]
public int Num { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2065e116928f06445bd193335b2181b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
namespace ET.Server
{
[UniqueId(1, 10000)]
public static class RobotCaseType
{
public const int FirstCase = 1;
public const int SecondCase = 2;
public const int MaxCaseType = 10000;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3715612a321cd8b40b5d217d0294528e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class RobotManagerComponent: Entity, IAwake
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c08dcea223e87cf48ae83e40abfffa7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 886c7abbc951ad14197420f7db46033e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
using System.Diagnostics;
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class WatcherComponent: Entity, IAwake
{
public readonly Dictionary<int, System.Diagnostics.Process> Processes = new Dictionary<int, System.Diagnostics.Process>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b13f7d5a781c9743ae1beb843cde393
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 78a1c559ee23b4ca2878b8d4710adc3f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4c628457f77814ca1a92b6d757ef4063
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
namespace ET.Server
{
[ComponentOf(typeof (Player))]
public class PlayerRoomComponent: Entity, IAwake
{
public ActorId RoomActorId { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd88fbf5ce4784f16a2907c22636ef3c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d0f1c516742bc43d586c085b7a26e12d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class RoomManagerComponent: Entity, IAwake
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48baea120fed34a2492026794df7f64b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
namespace ET.Server
{
[ChildOf(typeof (RoomServerComponent))]
public class RoomPlayer: Entity, IAwake
{
public int Progress { get; set; }
public bool IsOnline { get; set; } = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7cb46c73e983f4acb882077e517f6feb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace ET.Server
{
[ComponentOf(typeof(Room))]
public class RoomServerComponent: Entity, IAwake<List<long>>
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ab5631e2c7734968b6ac758ce81dd13
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d3d85a4b2a3594b9fa6887cc3b574056
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class MatchComponent: Entity, IAwake
{
public List<long> waitMatchPlayers = new List<long>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21a0976ebbc13407da27f69d27ed3976
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 78ca54cc32ca42a9861cd379ff3fc3e8
timeCreated: 1681817948

View File

@@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace ET.Server
{
[ComponentOf(typeof(Room))]
public class LSServerUpdater: Entity, IAwake, IUpdate
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f48eaf95cced640e8b7c6adc082dbd07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 50b89103390beda43874b94fdde62cbf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 92fbb093186ec1742acdcadde9b344b2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using System.Collections.Generic;
using Unity.Mathematics;
namespace ET.Server
{
[ComponentOf(typeof(Unit))]
public class AOIEntity: Entity, IAwake<int, float3>, IDestroy
{
public Unit Unit => this.GetParent<Unit>();
public int ViewDistance;
private EntityRef<Cell> cell;
public Cell Cell
{
get
{
return this.cell;
}
set
{
this.cell = value;
}
}
// 观察进入视野的Cell
public HashSet<long> SubEnterCells = new HashSet<long>();
// 观察离开视野的Cell
public HashSet<long> SubLeaveCells = new HashSet<long>();
// 观察进入视野的Cell
public HashSet<long> enterHashSet = new HashSet<long>();
// 观察离开视野的Cell
public HashSet<long> leaveHashSet = new HashSet<long>();
// 我看的见的Unit
public Dictionary<long, AOIEntity> SeeUnits = new Dictionary<long, AOIEntity>();
// 看见我的Unit
public Dictionary<long, AOIEntity> BeSeeUnits = new Dictionary<long, AOIEntity>();
// 我看的见的Player
public Dictionary<long, AOIEntity> SeePlayers = new Dictionary<long, AOIEntity>();
// 看见我的Player单独放一个Dict用于广播
public Dictionary<long, AOIEntity> BeSeePlayers = new Dictionary<long, AOIEntity>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 82e4e3a5d5dabb049bf406df3ec3dbd3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
namespace ET.Server
{
namespace EventType
{
public struct UnitEnterSightRange
{
public AOIEntity A;
public AOIEntity B;
}
public struct UnitLeaveSightRange
{
public AOIEntity A;
public AOIEntity B;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2fb3b7c085835bc45b9bf319fb179f8b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class AOIManagerComponent: Entity, IAwake
{
public const int CellSize = 10 * 1000;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ac4abb8f844e8543b742c9eb837c9e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace ET.Server
{
[ChildOf(typeof(AOIManagerComponent))]
public class Cell: Entity, IAwake, IDestroy
{
// 处在这个cell的单位
public Dictionary<long, AOIEntity> AOIUnits = new Dictionary<long, AOIEntity>();
// 订阅了这个Cell的进入事件
public Dictionary<long, AOIEntity> SubsEnterEntities = new Dictionary<long, AOIEntity>();
// 订阅了这个Cell的退出事件
public Dictionary<long, AOIEntity> SubsLeaveEntities = new Dictionary<long, AOIEntity>();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a75cc6d8fbc87d4386d2159f6ac48f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9310265e136b6074cac1754f44280871
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System.IO;
namespace ET.Server
{
// 知道对方的Id使用这个类发actor消息
[ChildOf(typeof(ActorLocationSenderOneType))]
public class ActorLocationSender: Entity, IAwake, IDestroy
{
public ActorId ActorId;
// 最近接收或者发送消息的时间
public long LastSendOrRecvTime;
public int Error;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f63a22fae23df55448bebaaa447e1bad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System.Collections.Generic;
namespace ET.Server
{
[ChildOf(typeof(ActorLocationSenderComponent))]
public class ActorLocationSenderOneType: Entity, IAwake<int>, IDestroy
{
public const long TIMEOUT_TIME = 60 * 1000;
public long CheckTimer;
public int LocationType;
}
[ComponentOf(typeof(Scene))]
public class ActorLocationSenderComponent: Entity, IAwake
{
public const long TIMEOUT_TIME = 60 * 1000;
public long CheckTimer;
public ActorLocationSenderOneType[] ActorLocationSenderComponents = new ActorLocationSenderOneType[LocationType.Max];
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe4c532cd914d4ad498b494298be81b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
namespace ET.Server
{
[UniqueId(0, 100)]
public static class LocationType
{
public const int Unit = 0;
public const int Player = 1;
public const int Friend = 2;
public const int Chat = 3;
public const int GateSession = 4;
public const int Max = 100;
}
[ChildOf(typeof(LocationOneType))]
public class LockInfo: Entity, IAwake<ActorId, CoroutineLock>, IDestroy
{
public ActorId LockActorId;
public CoroutineLock CoroutineLock
{
get;
set;
}
}
[ChildOf(typeof(LocationManagerComoponent))]
public class LocationOneType: Entity, IAwake<int>
{
public int LocationType;
public readonly Dictionary<long, ActorId> locations = new();
public readonly Dictionary<long, LockInfo> lockInfos = new();
}
[ComponentOf(typeof(Scene))]
public class LocationManagerComoponent: Entity, IAwake
{
public LocationOneType[] LocationOneTypes = new LocationOneType[LocationType.Max];
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 15d2e4888958d964399187bc1a29f0ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System;
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class LocationProxyComponent: Entity, IAwake
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33a386a4a4fc3a1428c59a2e07be246c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ce1b81735cfec4948a4652f0ac14d0ff
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using MongoDB.Driver;
namespace ET.Server
{
/// <summary>
/// 用来缓存数据
/// </summary>
[ChildOf(typeof(DBManagerComponent))]
public class DBComponent: Entity, IAwake<string, string, int>
{
public const int TaskCount = 32;
public MongoClient mongoClient;
public IMongoDatabase database;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aedf41755039b6542a26efbcd0b14745
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using System;
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class DBManagerComponent: Entity, IAwake
{
public DBComponent[] DBComponents = new DBComponent[IdGenerater.MaxZone];
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9064bf4ba5cdd044a80e66e16b3f07f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,6 @@
namespace ET.Server
{
public interface IDBCollection
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 88b90ba479aa3b748b225bddc153ba6d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1be6139db3006b9419935261c3d0414e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.Net;
namespace ET.Server
{
/// <summary>
/// http请求分发器
/// </summary>
[ComponentOf(typeof(Scene))]
public class HttpComponent: Entity, IAwake<string>, IDestroy
{
public HttpListener Listener;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0de2584d06993846b20ba44c51b8a0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
namespace ET.Server
{
public class HttpDispatcher: SingletonLock<HttpDispatcher>, ISingletonAwake
{
private readonly Dictionary<string, Dictionary<int, IHttpHandler>> dispatcher = new();
public override void Load()
{
World.Instance.AddSingleton<HttpDispatcher>();
}
public void Awake()
{
HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (HttpHandlerAttribute));
foreach (Type type in types)
{
object[] attrs = type.GetCustomAttributes(typeof(HttpHandlerAttribute), false);
if (attrs.Length == 0)
{
continue;
}
HttpHandlerAttribute httpHandlerAttribute = (HttpHandlerAttribute)attrs[0];
object obj = Activator.CreateInstance(type);
IHttpHandler ihttpHandler = obj as IHttpHandler;
if (ihttpHandler == null)
{
throw new Exception($"HttpHandler handler not inherit IHttpHandler class: {obj.GetType().FullName}");
}
if (!this.dispatcher.TryGetValue(httpHandlerAttribute.Path, out var dict))
{
dict = new Dictionary<int, IHttpHandler>();
this.dispatcher.Add(httpHandlerAttribute.Path, dict);
}
dict.Add((int)httpHandlerAttribute.SceneType, ihttpHandler);
}
}
public IHttpHandler Get(SceneType sceneType, string path)
{
return this.dispatcher[path][(int)sceneType];
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f32ee5a97327b54dad8859600342649
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
namespace ET.Server
{
public class HttpHandlerAttribute: BaseAttribute
{
public SceneType SceneType { get; }
public string Path { get; }
public HttpHandlerAttribute(SceneType sceneType, string path)
{
this.SceneType = sceneType;
this.Path = path;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 536bf765aeb46c44e9d0618fb418c76a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System.Net;
namespace ET.Server
{
public interface IHttpHandler
{
ETTask Handle(Scene scene, HttpListenerContext context);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 850082c851b74ff419893672cb613cf3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28793f12e3c15f140bd4d4d713d5782d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Net;
namespace ET.Server
{
[ComponentOf(typeof(Scene))]
public class ActorOuterComponent: Entity, IAwake<IPEndPoint>, IUpdate, IDestroy
{
public const long TIMEOUT_TIME = 40 * 1000;
public int RpcId;
public readonly Dictionary<int, ActorMessageSender> requestCallback = new();
public AService AService;
public NetworkProtocol InnerProtocol = NetworkProtocol.KCP;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 11d2abb5f986c5b44b5b58bfae58908f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace ET
{
[ComponentOf(typeof(Scene))]
public class ActorSenderComponent: Entity, IAwake, IDestroy
{
public const long TIMEOUT_TIME = 40 * 1000;
public int RpcId;
public readonly Dictionary<int, ActorMessageSender> requestCallback = new();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ecc41a2013820624bbe9d11dc8940dc8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
using System;
namespace ET.Server
{
public abstract class MessageHandler<Request, Response>: IMHandler where Request : MessageObject, IRequest where Response : MessageObject, IResponse
{
protected abstract ETTask Run(Session session, Request request, Response response);
public void Handle(Session session, object message)
{
HandleAsync(session, message).Coroutine();
}
private async ETTask HandleAsync(Session session, object message)
{
try
{
Request request = message as Request;
if (request == null)
{
throw new Exception($"消息类型转换错误: {message.GetType().FullName} to {typeof (Request).FullName}");
}
int rpcId = request.RpcId;
long instanceId = session.InstanceId;
Response response = ObjectPool.Instance.Fetch<Response>();
try
{
await this.Run(session, request, response);
}
catch (Exception exception)
{
Log.Error(exception);
response.Error = ErrorCore.ERR_RpcFail;
response.Message = exception.ToString();
}
// 等回调回来,session可以已经断开了,所以需要判断session InstanceId是否一样
if (session.InstanceId != instanceId)
{
return;
}
response.RpcId = rpcId; // 在这里设置rpcId是为了防止在Run中不小心修改rpcId字段
session.Send(response);
}
catch (Exception e)
{
throw new Exception($"解释消息失败: {message.GetType().FullName}", e);
}
}
public Type GetMessageType()
{
return typeof (Request);
}
public Type GetResponseType()
{
return typeof (Response);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e3881ad9cfc7dc343a107f25d5659fb1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System.Net;
namespace ET.Server
{
public struct NetServerComponentOnRead
{
public Session Session;
public object Message;
}
[ComponentOf(typeof(Scene))]
public class NetServerComponent: Entity, IAwake<IPEndPoint>, IDestroy, IUpdate
{
public AService AService;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6d26c818710bffb459fecf60387869b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89b0725638d94c1e9c36b262da2e447c
timeCreated: 1688535488

View File

@@ -0,0 +1,75 @@
using MemoryPack;
namespace ET
{
[Message(1)]
public class A2NetInner_Message: MessageObject, IActorMessage
{
public static A2NetInner_Message Create()
{
return ObjectPool.Instance.Fetch(typeof(A2NetInner_Message)) as A2NetInner_Message;
}
public override void Dispose()
{
this.FromAddress = default;
this.ActorId = default;
ObjectPool.Instance.Recycle(this);
}
public Address FromAddress;
public ActorId ActorId;
public IActorMessage MessageObject;
}
[Message(2)]
[ResponseType(nameof(A2NetInner_Response))]
public class A2NetInner_Request: MessageObject, IActorRequest
{
public static A2NetInner_Request Create()
{
return ObjectPool.Instance.Fetch(typeof(A2NetInner_Request)) as A2NetInner_Request;
}
public override void Dispose()
{
this.RpcId = default;
this.ActorId = default;
this.MessageObject = default;
this.NeedException = default;
ObjectPool.Instance.Recycle(this);
}
public int RpcId { get; set; }
public ActorId ActorId;
public bool NeedException;
public IActorRequest MessageObject;
}
[Message(3)]
public class A2NetInner_Response: MessageObject, IActorResponse
{
public static A2NetInner_Response Create()
{
return ObjectPool.Instance.Fetch(typeof(A2NetInner_Response)) as A2NetInner_Response;
}
public override void Dispose()
{
this.RpcId = default;
this.Error = default;
this.Message = default;
ObjectPool.Instance.Recycle(this);
}
public int Error { get; set; }
public string Message { get; set; }
public int RpcId { get; set; }
public IActorResponse MessageObject;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 49cfb0bef9f14131b988f817eff4313b
timeCreated: 1688535429

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45a2289132188ea4783d8a7858cf50ad
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More