diff --git a/Server/Lib/MongoDB.Driver.Core.dll b/Server/Lib/MongoDB.Driver.Core.dll new file mode 100644 index 0000000000000000000000000000000000000000..cd2f146e1d0b4a20d29ddcab5ef63eba59ed5432 Binary files /dev/null and b/Server/Lib/MongoDB.Driver.Core.dll differ diff --git a/Server/Lib/MongoDB.Driver.dll b/Server/Lib/MongoDB.Driver.dll new file mode 100644 index 0000000000000000000000000000000000000000..9bd6b675ba1b6121d9a79f3465222e7768f8cd67 Binary files /dev/null and b/Server/Lib/MongoDB.Driver.dll differ diff --git a/Server/Lib/Newtonsoft.Json.dll b/Server/Lib/Newtonsoft.Json.dll new file mode 100644 index 0000000000000000000000000000000000000000..e5c8978e063e0dd38ea4cf793192872a4c259681 Binary files /dev/null and b/Server/Lib/Newtonsoft.Json.dll differ diff --git a/Server/Model/Component/Config/DBConfig.cs b/Server/Model/Component/Config/DBConfig.cs new file mode 100644 index 0000000000000000000000000000000000000000..cb9d743e41ff37019101bde02eab22ae896f19dc --- /dev/null +++ b/Server/Model/Component/Config/DBConfig.cs @@ -0,0 +1,11 @@ +using MongoDB.Bson.Serialization.Attributes; + +namespace Model +{ + [BsonIgnoreExtraElements] + public class DBConfig : AConfigComponent + { + public string ConnectionString { get; set; } + public string DBName { get; set; } + } +} \ No newline at end of file diff --git a/Server/Model/Component/Config/HttpConfig.cs b/Server/Model/Component/Config/HttpConfig.cs new file mode 100644 index 0000000000000000000000000000000000000000..9d10ffbfe8828d31f55202fe90f82e3353c5e7b2 --- /dev/null +++ b/Server/Model/Component/Config/HttpConfig.cs @@ -0,0 +1,13 @@ +using MongoDB.Bson.Serialization.Attributes; + +namespace Model +{ + [BsonIgnoreExtraElements] + public class HttpConfig : AConfigComponent + { + public string Url { get; set; } = ""; + public int AppId { get; set; } + public string AppKey { get; set; } = ""; + public string ManagerSystemUrl { get; set; } = ""; + } +} \ No newline at end of file diff --git a/Server/Model/Component/DBCacheComponent.cs b/Server/Model/Component/DBCacheComponent.cs new file mode 100644 index 0000000000000000000000000000000000000000..cf6fdc83751e2549a1713afa40d3660d68ac83b2 --- /dev/null +++ b/Server/Model/Component/DBCacheComponent.cs @@ -0,0 +1,150 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Model +{ + [ObjectEvent] + public class DBCacheComponentEvent : ObjectEvent, IAwake + { + public void Awake() + { + this.Get().Awake(); + } + } + + /// + /// 用来缓存数据 + /// + public class DBCacheComponent : Component + { + public Dictionary> cache = new Dictionary>(); + + public const int taskCount = 32; + public List tasks = new List(taskCount); + + public void Awake() + { + for (int i = 0; i < taskCount; ++i) + { + DBTaskQueue taskQueue = new DBTaskQueue(); + this.tasks.Add(taskQueue); + taskQueue.Start(); + } + } + + public Task Add(Entity entity, string collectionName = "") + { + TaskCompletionSource tcs = new TaskCompletionSource(); + + this.AddToCache(entity, collectionName); + + if (collectionName == "") + { + collectionName = entity.GetType().Name; + } + DBSaveTask task = new DBSaveTask(entity, collectionName, tcs); + this.tasks[(int)((ulong)task.Id % taskCount)].Add(task); + + return tcs.Task; + } + + public Task AddBatch(List entitys, string collectionName) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + DBSaveBatchTask task = new DBSaveBatchTask(entitys, collectionName, tcs); + this.tasks[(int)((ulong)task.Id % taskCount)].Add(task); + return tcs.Task; + } + + public void AddToCache(Entity entity, string collectionName = "") + { + if (collectionName == "") + { + collectionName = entity.GetType().Name; + } + Dictionary collection; + if (!this.cache.TryGetValue(collectionName, out collection)) + { + collection = new Dictionary(); + this.cache.Add(collectionName, collection); + } + collection[entity.Id] = entity; + } + + public Entity GetFromCache(string collectionName, long id) + { + Dictionary d; + if (!this.cache.TryGetValue(collectionName, out d)) + { + return null; + } + Entity result; + if (!d.TryGetValue(id, out result)) + { + return null; + } + return result; + } + + public void RemoveFromCache(string collectionName, long id) + { + Dictionary d; + if (!this.cache.TryGetValue(collectionName, out d)) + { + return; + } + d.Remove(id); + } + + public Task Get(string collectionName, long id) + { + Entity entity = GetFromCache(collectionName, id); + if (entity != null) + { + return Task.FromResult(entity); + } + + TaskCompletionSource tcs = new TaskCompletionSource(); + this.tasks[(int)((ulong)id % taskCount)].Add(new DBQueryTask(id, collectionName, tcs)); + + return tcs.Task; + } + + public Task> GetBatch(string collectionName, List idList) + { + List entitys = new List(); + bool isAllInCache = true; + foreach (long id in idList) + { + Entity entity = this.GetFromCache(collectionName, id); + if (entity == null) + { + isAllInCache = false; + break; + } + entitys.Add(entity); + } + + if (isAllInCache) + { + return Task.FromResult(entitys); + } + + TaskCompletionSource> tcs = new TaskCompletionSource>(); + DBQueryBatchTask dbQueryBatchTask = new DBQueryBatchTask(idList, collectionName, tcs); + this.tasks[(int)((ulong)dbQueryBatchTask.Id % taskCount)].Add(dbQueryBatchTask); + + return tcs.Task; + } + + public Task> GetJson(string collectionName, string json) + { + TaskCompletionSource> tcs = new TaskCompletionSource>(); + + DBQueryJsonTask dbQueryJsonTask = new DBQueryJsonTask(collectionName, json, tcs); + this.tasks[(int)((ulong)dbQueryJsonTask.Id % taskCount)].Add(dbQueryJsonTask); + + return tcs.Task; + } + } +} \ No newline at end of file diff --git a/Server/Model/Component/DBComponent.cs b/Server/Model/Component/DBComponent.cs new file mode 100644 index 0000000000000000000000000000000000000000..de8571ca373e08efe20ae14f383da637a959638c --- /dev/null +++ b/Server/Model/Component/DBComponent.cs @@ -0,0 +1,35 @@ +using MongoDB.Driver; + +namespace Model +{ + [ObjectEvent] + public class DBComponentEvent : ObjectEvent, IAwake + { + public void Awake() + { + this.Get().Awake(); + } + } + + /// + /// 连接mongodb + /// + public class DBComponent : Component + { + public MongoClient mongoClient; + public IMongoDatabase database; + + public void Awake() + { + DBConfig config = Game.Scene.GetComponent().StartConfig.GetComponent(); + string connectionString = config.ConnectionString; + mongoClient = new MongoClient(connectionString); + this.database = this.mongoClient.GetDatabase(config.DBName); + } + + public IMongoCollection GetCollection(string name) + { + return this.database.GetCollection(name); + } + } +} \ No newline at end of file diff --git a/Server/Model/Component/DBProxyComponent.cs b/Server/Model/Component/DBProxyComponent.cs new file mode 100644 index 0000000000000000000000000000000000000000..26d2976dc822074dfac2a2f7d0166aac60ee66f5 --- /dev/null +++ b/Server/Model/Component/DBProxyComponent.cs @@ -0,0 +1,75 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Model +{ + /// + /// 用来与数据库操作代理 + /// + public class DBProxyComponent : Component + { + public string dbAddress; + + public void Awake() + { + StartConfig dbStartConfig = Game.Scene.GetComponent().DBStartConfig; + dbAddress = dbStartConfig.GetComponent().Address; + } + + public async Task Save(Entity entity, bool needCache = true) + { + Session session = Game.Scene.GetComponent().Get(dbAddress); + await session.Call(new DBSaveRequest { Entity = entity, NeedCache = needCache}); + } + + public async Task SaveBatch(List entitys, bool needCache = true) + { + Session session = Game.Scene.GetComponent().Get(dbAddress); + await session.Call(new DBSaveBatchRequest { Entitys = entitys, NeedCache = needCache}); + } + + public async Task Save(Entity entity, bool needCache, CancellationToken cancellationToken) + { + Session session = Game.Scene.GetComponent().Get(dbAddress); + await session.Call(new DBSaveRequest { Entity = entity, NeedCache = needCache}, cancellationToken); + } + + public async void SaveLog(Entity entity) + { + Session session = Game.Scene.GetComponent().Get(dbAddress); + await session.Call(new DBSaveRequest { Entity = entity, NeedCache = false, CollectionName = "Log" }); + } + + public async Task Query(long id, bool needCache = true) where T: Entity + { + Session session = Game.Scene.GetComponent().Get(dbAddress); + DBQueryResponse dbQueryResponse = await session.Call(new DBQueryRequest { CollectionName = typeof(T).Name, Id = id, NeedCache = needCache }); + return (T)dbQueryResponse.Entity; + } + + public async Task> QueryBatch(List ids, bool needCache = true) where T : Entity + { + List list = new List(); + Session session = Game.Scene.GetComponent().Get(dbAddress); + DBQueryBatchResponse dbQueryBatchResponse = await session.Call(new DBQueryBatchRequest { CollectionName = typeof(T).Name, IdList = ids, NeedCache = needCache}); + foreach (Entity entity in dbQueryBatchResponse.Entitys) + { + list.Add((T)entity); + } + return list; + } + + public async Task> QueryJson(string json, bool needCache = true) where T : Entity + { + List list = new List(); + Session session = Game.Scene.GetComponent().Get(dbAddress); + DBQueryJsonResponse dbQueryJsonResponse = await session.Call(new DBQueryJsonRequest { CollectionName = typeof(T).Name, Json = json, NeedCache = needCache}); + foreach (Entity entity in dbQueryJsonResponse.Entitys) + { + list.Add((T)entity); + } + return list; + } + } +} \ No newline at end of file diff --git a/Server/Model/Component/StartConfigComponent.cs b/Server/Model/Component/StartConfigComponent.cs index 617445bca1823974da6b9fa139e9906650e2afc0..829e622823b04501e5f3ee6e8f6eb8a89f9975fe 100644 --- a/Server/Model/Component/StartConfigComponent.cs +++ b/Server/Model/Component/StartConfigComponent.cs @@ -22,6 +22,10 @@ namespace Model public StartConfig StartConfig { get; private set; } + public StartConfig DBStartConfig { get; private set; } + + public StartConfig RealmConfig { get; private set; } + public void Awake(string path, int appId) { string[] ss = File.ReadAllText(path).Split('\n'); diff --git a/Server/Model/Config/AConfig.cs b/Server/Model/Config/AConfig.cs index a3691c5e36707f2a801b7d0a00cb12f7ee5b13e7..d24f8101344403a88530ed04fd63ec5bed8c9859 100644 --- a/Server/Model/Config/AConfig.cs +++ b/Server/Model/Config/AConfig.cs @@ -5,11 +5,11 @@ /// public abstract class AConfig: Entity { - protected AConfig(EntityType entityType): base(entityType) + protected AConfig() { } - protected AConfig(long id, EntityType entityType): base(id, entityType) + protected AConfig(long id): base(id) { } } diff --git a/Server/Model/Entity/Config/BuffConfig.cs b/Server/Model/Entity/Config/BuffConfig.cs index f54cf2123d6b32c54f5982fbd49059d7236b9013..ec6d42b7b62d2972c35a40bac8b3230e32ae631d 100644 --- a/Server/Model/Entity/Config/BuffConfig.cs +++ b/Server/Model/Entity/Config/BuffConfig.cs @@ -8,11 +8,11 @@ namespace Model public string Name { get; set; } public int Time { get; set; } - public BuffConfig(): base(EntityType.Config) + public BuffConfig() { } - public BuffConfig(long id): base(id, EntityType.Config) + public BuffConfig(long id): base(id) { } } diff --git a/Server/Model/Entity/Config/StartConfig.cs b/Server/Model/Entity/Config/StartConfig.cs index 610d11dc60c865ae4313aaca82b381754b66adfe..22dc456d2072cad2192ac3bf92b96c75940e4a1a 100644 --- a/Server/Model/Entity/Config/StartConfig.cs +++ b/Server/Model/Entity/Config/StartConfig.cs @@ -11,9 +11,5 @@ namespace Model public AppType AppType { get; set; } public string ServerIP { get; set; } - - public StartConfig(): base(EntityType.Config) - { - } } } \ No newline at end of file diff --git a/Server/Model/Entity/DBEntity.cs b/Server/Model/Entity/DBEntity.cs new file mode 100644 index 0000000000000000000000000000000000000000..30c77a2232c18ba0c8ebac9de9a875e5cd12d387 --- /dev/null +++ b/Server/Model/Entity/DBEntity.cs @@ -0,0 +1,18 @@ +using MongoDB.Bson.Serialization.Attributes; + +namespace Model +{ + [BsonIgnoreExtraElements] + [BsonKnownTypes(typeof(RechargeRecord))] + [BsonKnownTypes(typeof(Recharge))] + public class DBEntity: Entity + { + protected DBEntity() + { + } + + protected DBEntity(long id): base(id) + { + } + } +} diff --git a/Server/Model/Entity/DBTask.cs b/Server/Model/Entity/DBTask.cs new file mode 100644 index 0000000000000000000000000000000000000000..f715e5b1cb52f1f8f69f4119f2c345c5d6c3e124 --- /dev/null +++ b/Server/Model/Entity/DBTask.cs @@ -0,0 +1,217 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Base; +using Model; +using MongoDB.Bson; +using MongoDB.Driver; + +namespace Model +{ + public abstract class DBTask : Entity + { + protected DBTask() + { + } + + protected DBTask(long id): base(id) + { + } + + public abstract Task Run(); + } + + public sealed class DBSaveTask : DBTask + { + public Entity Entity; + + public string CollectionName { get; } + + public TaskCompletionSource Tcs; + + public DBSaveTask(Entity entity, string collectionName, TaskCompletionSource tcs) : base(entity.Id) + { + this.Entity = entity; + this.CollectionName = collectionName; + this.Tcs = tcs; + } + + public override async Task Run() + { + DBComponent dbComponent = Game.Scene.GetComponent(); + + try + { + // 执行保存数据库任务 + await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == this.Entity.Id, this.Entity, new UpdateOptions {IsUpsert = true}); + this.Tcs.SetResult(true); + } + catch (Exception e) + { + this.Tcs.SetException(new Exception($"保存数据失败! {CollectionName} {Id}", e)); + } + } + } + + public sealed class DBSaveBatchTask : DBTask + { + public string CollectionName { get; } + + public List Entitys; + + public TaskCompletionSource Tcs; + + public DBSaveBatchTask(List entitys, string collectionName, TaskCompletionSource tcs) + { + this.Entitys = entitys; + this.CollectionName = collectionName; + this.Tcs = tcs; + } + + public override async Task Run() + { + DBComponent dbComponent = Game.Scene.GetComponent(); + + foreach (Entity entity in this.Entitys) + { + if (entity == null) + { + continue; + } + + try + { + // 执行保存数据库任务 + await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == entity.Id, entity, new UpdateOptions { IsUpsert = true }); + } + catch (Exception e) + { + Log.Debug($"{entity.GetType().Name} {entity.ToJson()}" + e.ToString()); + this.Tcs.SetException(new Exception($"保存数据失败! {CollectionName} {this.Entitys.ListToString()}", e)); + } + } + this.Tcs.SetResult(true); + } + } + + public sealed class DBQueryTask : DBTask + { + public string CollectionName { get; } + + public TaskCompletionSource Tcs { get; } + + public DBQueryTask(long id, string collectionName, TaskCompletionSource tcs) : base(id) + { + this.CollectionName = collectionName; + this.Tcs = tcs; + } + + public override async Task Run() + { + DBCacheComponent dbCacheComponent = Game.Scene.GetComponent(); + DBComponent dbComponent = Game.Scene.GetComponent(); + // 执行查询前先看看cache中是否已经存在 + Entity entity = dbCacheComponent.GetFromCache(this.CollectionName, this.Id); + if (entity != null) + { + this.Tcs.SetResult(entity); + return; + } + try + { + // 执行查询数据库任务 + entity = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == this.Id).Result.FirstOrDefaultAsync(); + if (entity != null) + { + dbCacheComponent.AddToCache(entity); + } + this.Tcs.SetResult(entity); + } + catch (Exception e) + { + this.Tcs.SetException(new Exception($"查询数据库异常! {CollectionName} {Id}", e)); + } + } + } + + public sealed class DBQueryBatchTask : DBTask + { + public string CollectionName { get; } + + public List IdList { get; } + + public TaskCompletionSource> Tcs { get; } + + public DBQueryBatchTask(List list, string collectionName, TaskCompletionSource> tcs) + { + this.IdList = list; + this.CollectionName = collectionName; + this.Tcs = tcs; + } + + public override async Task Run() + { + DBCacheComponent dbCacheComponent = Game.Scene.GetComponent(); + DBComponent dbComponent = Game.Scene.GetComponent(); + List result = new List(); + + try + { + // 执行查询数据库任务 + foreach (long id in IdList) + { + Entity entity = dbCacheComponent.GetFromCache(this.CollectionName, id); + if (entity == null) + { + entity = await dbComponent.GetCollection(this.CollectionName).FindAsync((s) => s.Id == id).Result.FirstOrDefaultAsync(); + dbCacheComponent.AddToCache(entity); + } + + if (entity == null) + { + continue; + } + result.Add(entity); + } + + this.Tcs.SetResult(result); + } + catch (Exception e) + { + this.Tcs.SetException(new Exception($"查询数据库异常! {this.CollectionName} {IdList.ListToString()}", e)); + } + } + } + + public sealed class DBQueryJsonTask : DBTask + { + public string CollectionName { get; } + + public string Json { get; } + + public TaskCompletionSource> Tcs { get; } + + public DBQueryJsonTask(string collectionName, string json, TaskCompletionSource> tcs) + { + this.CollectionName = collectionName; + this.Json = json; + this.Tcs = tcs; + } + + public override async Task Run() + { + DBComponent dbComponent = Game.Scene.GetComponent(); + try + { + // 执行查询数据库任务 + FilterDefinition filterDefinition = new JsonFilterDefinition(this.Json); + List entitys = await dbComponent.GetCollection(this.CollectionName).FindAsync(filterDefinition).Result.ToListAsync(); + this.Tcs.SetResult(entitys); + } + catch (Exception e) + { + this.Tcs.SetException(new Exception($"查询数据库异常! {CollectionName} {this.Json}", e)); + } + } + } +} \ No newline at end of file diff --git a/Server/Model/Entity/DBTaskQueue.cs b/Server/Model/Entity/DBTaskQueue.cs new file mode 100644 index 0000000000000000000000000000000000000000..a8563cb68daa77b3082475b77125a255d20fc4d0 --- /dev/null +++ b/Server/Model/Entity/DBTaskQueue.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Base; +using Model; + +namespace Model +{ + public sealed class DBTaskQueue : Entity + { + public Queue queue = new Queue(); + + private TaskCompletionSource tcs; + + public async void Start() + { + while (true) + { + if (this.Id == 0) + { + return; + } + + DBTask task = await this.Get(); + + try + { + await task.Run(); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } + } + } + public void Add(DBTask task) + { + if (this.tcs != null) + { + var t = this.tcs; + this.tcs = null; + t.SetResult(task); + return; + } + + this.queue.Enqueue(task); + } + + public Task Get() + { + TaskCompletionSource t = new TaskCompletionSource(); + if (this.queue.Count > 0) + { + DBTask task = this.queue.Dequeue(); + t.SetResult(task); + } + else + { + this.tcs = t; + } + return t.Task; + } + } +} \ No newline at end of file diff --git a/Server/Model/Entity/Http.cs b/Server/Model/Entity/Http.cs new file mode 100644 index 0000000000000000000000000000000000000000..3aa35f7274aaedb1efe34b0c0e43ba378771d589 --- /dev/null +++ b/Server/Model/Entity/Http.cs @@ -0,0 +1,45 @@ +namespace Model +{ + // 充值流水 + public sealed class RechargeRecord : DBEntity + { + // 充值玩家 + public int PlayerNO { get; set; } + + // 充值数量 + public int CardNumber { get; set; } + + // 充值时间 + public long Time { get; set; } + + public RechargeRecord(long id): base(id) + { + } + } + + // 保存玩家充值记录, 每个玩家只有一条 + public sealed class Recharge : DBEntity + { + public int CardNumber { get; set; } + + public long UpdateTime { get; set; } + + public Recharge(long id): base(id) + { + } + } + + public class HttpResult + { + public int code; + public bool status; + public string msg = ""; + } + + public static class HttpErrorCode + { + public const int Exception = 999; + public const int Success = 1000; + public const int RpcFail = 1002; + } +} \ No newline at end of file diff --git a/Server/Model/Entity/Message/InnerMessage.cs b/Server/Model/Entity/Message/InnerMessage.cs index c64b6f18e5822f3160859434993f889c190b2bf4..806769705708eb8b0385a5299460a76565817dfa 100644 --- a/Server/Model/Entity/Message/InnerMessage.cs +++ b/Server/Model/Entity/Message/InnerMessage.cs @@ -1,68 +1,44 @@ -using MongoDB.Bson.Serialization.Attributes; +using System.Collections.Generic; + using MongoDB.Bson.Serialization.Attributes; // ڲϢ Opcode10000ʼ - namespace Model - { - [Message(10001)] - [BsonIgnoreExtraElements] - public class R2G_GetLoginKey: ARequest - { - } - - [Message(10002)] - [BsonIgnoreExtraElements] - public class G2R_GetLoginKey: AResponse - { - public long Key; - - public G2R_GetLoginKey() - { - } - - public G2R_GetLoginKey(long key) - { - this.Key = key; - } - } - - [Message(10003)] - [BsonIgnoreExtraElements] - public class M2A_Reload: ARequest - { - } - - [Message(10004)] - [BsonIgnoreExtraElements] - public class A2M_Reload: AResponse - { - } - - [Message(10005)] - [BsonIgnoreExtraElements] - public class G2G_LockRequest: ARequest - { - public long Id; - public string Address; - } - - [Message(10006)] - [BsonIgnoreExtraElements] - public class G2G_LockResponse: AResponse - { - } - - [Message(10007)] - [BsonIgnoreExtraElements] - public class G2G_LockReleaseRequest: ARequest - { - public long Id; - public string Address; - } - - [Message(10008)] - [BsonIgnoreExtraElements] - public class G2G_LockReleaseResponse: AResponse - { - } - } \ No newline at end of file + namespace Model { [Message(Opcode.R2G_GetLoginKey)] [BsonIgnoreExtraElements] public class R2G_GetLoginKey : ARequest { } + + [Message(Opcode.G2R_GetLoginKey)] [BsonIgnoreExtraElements] public class G2R_GetLoginKey : AResponse { public long Key; + public G2R_GetLoginKey() { } + public G2R_GetLoginKey(long key) { this.Key = key; } } + + [Message(Opcode.M2A_Reload)] [BsonIgnoreExtraElements] public class M2A_Reload : ARequest { } + + [Message(Opcode.A2M_Reload)] [BsonIgnoreExtraElements] public class A2M_Reload : AResponse { } + + [Message(Opcode.G2G_LockRequest)] [BsonIgnoreExtraElements] public class G2G_LockRequest : ARequest { public string Address; } + + [Message(Opcode.G2G_LockResponse)] [BsonIgnoreExtraElements] + public class G2G_LockResponse : AResponse { } + + [Message(Opcode.G2G_LockReleaseRequest)] [BsonIgnoreExtraElements] public class G2G_LockReleaseRequest : ARequest { public string Address; } + + [Message(Opcode.G2G_LockReleaseResponse)] [BsonIgnoreExtraElements] public class G2G_LockReleaseResponse : AResponse { } + [Message(Opcode.DBSaveRequest)] [BsonIgnoreExtraElements] public class DBSaveRequest : ARequest { public bool NeedCache = true; + public string CollectionName = ""; + public Entity Entity; } + + + [Message(Opcode.DBSaveBatchResponse)] [BsonIgnoreExtraElements] public class DBSaveBatchResponse : AResponse { } + + [Message(Opcode.DBSaveBatchRequest)] [BsonIgnoreExtraElements] public class DBSaveBatchRequest : ARequest { public bool NeedCache = true; public string CollectionName = ""; public List Entitys = new List(); } + + [Message(Opcode.DBSaveResponse)] [BsonIgnoreExtraElements] public class DBSaveResponse : AResponse { } + + [Message(Opcode.DBQueryRequest)] [BsonIgnoreExtraElements] public class DBQueryRequest : ARequest { public string CollectionName { get; set; } public bool NeedCache = true; } + + [Message(Opcode.DBQueryResponse)] [BsonIgnoreExtraElements] public class DBQueryResponse : AResponse { public Entity Entity; } + + [Message(Opcode.DBQueryBatchRequest)] [BsonIgnoreExtraElements] public class DBQueryBatchRequest : ARequest { public string CollectionName { get; set; } public List IdList { get; set; } public bool NeedCache = true; } + [Message(Opcode.DBQueryBatchResponse)] [BsonIgnoreExtraElements] public class DBQueryBatchResponse : AResponse { public List Entitys; } + + [Message(Opcode.DBQueryJsonRequest)] [BsonIgnoreExtraElements] public class DBQueryJsonRequest : ARequest { public string CollectionName { get; set; } public string Json { get; set; } public bool NeedCache = true; } + + [Message(Opcode.DBQueryJsonResponse)] [BsonIgnoreExtraElements] public class DBQueryJsonResponse : AResponse { public List Entitys; } } \ No newline at end of file diff --git a/Server/Model/Entity/Message/Opcode.cs b/Server/Model/Entity/Message/Opcode.cs index fd962dd85308883d71e9ff64a62ab2031a1ca9df..946ce992d8cf50339f0989bac366cbfeb56f137e 100644 --- a/Server/Model/Entity/Message/Opcode.cs +++ b/Server/Model/Entity/Message/Opcode.cs @@ -1,19 +1,36 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Model +namespace Model { public static class Opcode { - public const ushort C2R_Login = 1; - public const ushort R2C_Login = 2; - public const ushort R2C_ServerLog = 3; - public const ushort C2G_LoginGate = 4; - public const ushort G2C_LoginGate = 5; - public const ushort C2G_GetPlayerInfo = 6; - public const ushort G2C_GetPlayerInfo = 7; - public const ushort C2M_Reload = 8; + public const ushort G2G_LockRequest = 10; + public const ushort G2G_LockResponse = 11; + public const ushort G2G_LockReleaseRequest = 12; + public const ushort G2G_LockReleaseResponse = 13; + + public const ushort M2A_Reload = 20; + public const ushort A2M_Reload = 21; + + public const ushort DBSaveRequest = 26; + public const ushort DBSaveResponse = 27; + public const ushort DBQueryRequest = 28; + public const ushort DBQueryResponse = 29; + public const ushort DBSaveBatchResponse = 37; + public const ushort DBSaveBatchRequest = 38; + public const ushort DBQueryBatchRequest = 61; + public const ushort DBQueryBatchResponse = 62; + public const ushort DBQueryJsonRequest = 65; + public const ushort DBQueryJsonResponse = 66; + + public const ushort C2R_Login = 1000; + public const ushort R2C_Login = 1002; + public const ushort R2C_ServerLog = 1003; + public const ushort C2G_LoginGate = 1004; + public const ushort G2C_LoginGate = 1005; + public const ushort C2G_GetPlayerInfo = 1006; + public const ushort G2C_GetPlayerInfo = 1007; + public const ushort C2M_Reload = 1008; + + public const ushort R2G_GetLoginKey = 10001; + public const ushort G2R_GetLoginKey = 10002; } } diff --git a/Server/Model/Entity/Scene.cs b/Server/Model/Entity/Scene.cs index 25ed10dd7a8ee0af70295e9d1f148434a0640c92..4da4aa4a86d3c808055bb353a4fdbaf38ae6b916 100644 --- a/Server/Model/Entity/Scene.cs +++ b/Server/Model/Entity/Scene.cs @@ -23,11 +23,11 @@ public SceneType SceneType { get; private set; } - public Scene(): base(EntityType.Scene) + public Scene() { } - public Scene(long id): base(id, EntityType.Scene) + public Scene(long id): base(id) { } diff --git a/Server/Model/Entity/Unit.cs b/Server/Model/Entity/Unit.cs index 33daa5ee1ae1c4bb31731e370f084c3468e61482..b35cafb0e7302355b69f052ba40edbfa35a82f06 100644 --- a/Server/Model/Entity/Unit.cs +++ b/Server/Model/Entity/Unit.cs @@ -20,7 +20,7 @@ base.Dispose(); } - public Unit(UnitType unitType): base(EntityType.UI) + public Unit(UnitType unitType) { this.UnitType = unitType; } diff --git a/Server/Model/Object/Entity.cs b/Server/Model/Object/Entity.cs index 23dca10572d6d0854dc7d5acf180f006f581b008..5d1f964d65523d047daccac8f1f2ad639c1fdc21 100644 --- a/Server/Model/Object/Entity.cs +++ b/Server/Model/Object/Entity.cs @@ -19,19 +19,11 @@ namespace Model protected Entity() { - this.Type = EntityType.None; ObjectEvents.Instance.Add(this); } - protected Entity(EntityType entityType) + protected Entity(long id): base(id) { - this.Type = entityType; - ObjectEvents.Instance.Add(this); - } - - protected Entity(long id, EntityType entityType): base(id) - { - this.Type = entityType; ObjectEvents.Instance.Add(this); } diff --git a/Server/Model/Server.Model.csproj b/Server/Model/Server.Model.csproj index 04557e4c66bf845f923dbfb793940bdfc183130a..5c1d906e29f957b809955a466ad9f19fe8340186 100644 --- a/Server/Model/Server.Model.csproj +++ b/Server/Model/Server.Model.csproj @@ -34,9 +34,16 @@ False ..\Lib\CommandLine.dll - + + False ..\Lib\MongoDB.Bson.dll + + ..\Lib\MongoDB.Driver.dll + + + ..\Lib\MongoDB.Driver.Core.dll + @@ -44,8 +51,13 @@ + + + + + @@ -70,7 +82,11 @@ + + + + diff --git a/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs b/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs index 304ca26b99f6c5d316d27c7ee2af524f5e9d90c9..a2806af6311e1bfd4d9e60386f59f49f766ed7ee 100644 --- a/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs +++ b/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs @@ -24,7 +24,7 @@ namespace MyEditor private int copyNum = 1; - private AppType AppType = AppType.Manager; + private AppType AppType = AppType.None; private readonly List startConfigs = new List(); @@ -199,6 +199,8 @@ namespace MyEditor { GUILayout.Label($"OuterHost:"); outerConfig.Host = EditorGUILayout.TextField(outerConfig.Host); + GUILayout.Label($"OuterHost2:"); + outerConfig.Host2 = EditorGUILayout.TextField(outerConfig.Host2); GUILayout.Label($"OuterPort:"); outerConfig.Port = EditorGUILayout.IntField(outerConfig.Port); } @@ -212,6 +214,29 @@ namespace MyEditor clientConfig.Port = EditorGUILayout.IntField(clientConfig.Port); } + HttpConfig httpConfig = startConfig.GetComponent(); + if (httpConfig != null) + { + GUILayout.Label($"AppId:"); + httpConfig.AppId = EditorGUILayout.IntField(httpConfig.AppId); + GUILayout.Label($"AppKey:"); + httpConfig.AppKey = EditorGUILayout.TextField(httpConfig.AppKey); + GUILayout.Label($"Url:"); + httpConfig.Url = EditorGUILayout.TextField(httpConfig.Url); + GUILayout.Label($"ManagerSystemUrl:"); + httpConfig.ManagerSystemUrl = EditorGUILayout.TextField(httpConfig.ManagerSystemUrl); + } + + DBConfig dbConfig = startConfig.GetComponent(); + if (dbConfig != null) + { + GUILayout.Label($"Connection:"); + dbConfig.ConnectionString = EditorGUILayout.TextField(dbConfig.ConnectionString); + + GUILayout.Label($"DBName:"); + dbConfig.DBName = EditorGUILayout.TextField(dbConfig.DBName); + } + if (GUILayout.Button("删除")) { this.startConfigs.Remove(startConfig); @@ -227,6 +252,36 @@ namespace MyEditor } break; } + + if (i > 0) + { + if (GUILayout.Button("上移")) + { + StartConfig s = this.startConfigs[i]; + this.startConfigs.RemoveAt(i); + this.startConfigs.Insert(i - 1, s); + for (int j = 0; j < startConfigs.Count; ++j) + { + this.startConfigs[j].AppId = j + 1; + } + break; + } + } + + if (i < this.startConfigs.Count - 1) + { + if (GUILayout.Button("下移")) + { + StartConfig s = this.startConfigs[i]; + this.startConfigs.RemoveAt(i); + this.startConfigs.Insert(i + 1, s); + for (int j = 0; j < startConfigs.Count; ++j) + { + this.startConfigs[j].AppId = j + 1; + } + break; + } + } GUILayout.EndHorizontal(); } @@ -246,15 +301,29 @@ namespace MyEditor if (this.AppType.Is(AppType.Gate | AppType.Realm | AppType.Manager)) { - newStartConfig.AddComponent(); newStartConfig.AddComponent(); } + if (this.AppType.Is(AppType.Gate | AppType.Realm | AppType.Manager | AppType.Http | AppType.DB)) + { + newStartConfig.AddComponent(); + } + if (this.AppType.Is(AppType.Benchmark)) { newStartConfig.AddComponent(); } + if (this.AppType.Is(AppType.Http)) + { + newStartConfig.AddComponent(); + } + + if (this.AppType.Is(AppType.DB)) + { + newStartConfig.AddComponent(); + } + this.startConfigs.Add(newStartConfig); } GUILayout.EndHorizontal(); diff --git a/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs.meta b/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs.meta index 20a33185152be8e729ab1bc35c8f8581cf5bd046..974d260fd006eb2e14db9f9c0576d6c0fd4ce114 100644 --- a/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs.meta +++ b/Unity/Assets/Editor/ServerCommandLineEditor/ServerCommandLineEditor.cs.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: f87d124589b266d41a4281a2a6ba3f63 -timeCreated: 1476673528 -licenseType: Pro +timeCreated: 1498900429 +licenseType: Free MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Unity/Assets/Scripts/BehaviorTree/NodeDesignerProto.cs b/Unity/Assets/Scripts/BehaviorTree/NodeDesignerProto.cs index fb26d023333e3d5f3b60192dfd2e3acc3b5c0d10..d0d02dc71316bca9752673dd742a0f7345690759 100644 --- a/Unity/Assets/Scripts/BehaviorTree/NodeDesignerProto.cs +++ b/Unity/Assets/Scripts/BehaviorTree/NodeDesignerProto.cs @@ -6,9 +6,5 @@ namespace Model public float x = 0; public float y = 0; public bool fold = false; - - public NodeDesignerProto(): base(EntityType.Config) - { - } } } \ No newline at end of file diff --git a/Unity/Assets/Scripts/Entity/Config.meta b/Unity/Assets/Scripts/Component/Config.meta similarity index 100% rename from Unity/Assets/Scripts/Entity/Config.meta rename to Unity/Assets/Scripts/Component/Config.meta diff --git a/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs b/Unity/Assets/Scripts/Component/Config/BuffConfig.cs similarity index 69% rename from Unity/Assets/Scripts/Entity/Config/BuffConfig.cs rename to Unity/Assets/Scripts/Component/Config/BuffConfig.cs index 63dc0617fcadc39cd7c9d5a858d8246449812360..bf5d9c24093dec138a120a44b1cd561a3bb4c065 100644 --- a/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs +++ b/Unity/Assets/Scripts/Component/Config/BuffConfig.cs @@ -5,11 +5,11 @@ public string Name { get; set; } public int Time { get; set; } - public BuffConfig(): base(EntityType.Config) + public BuffConfig() { } - public BuffConfig(long id): base(id, EntityType.Config) + public BuffConfig(long id): base(id) { } } diff --git a/Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/BuffConfig.cs.meta similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta rename to Unity/Assets/Scripts/Component/Config/BuffConfig.cs.meta diff --git a/Unity/Assets/Scripts/Entity/Config/ClientConfig.cs b/Unity/Assets/Scripts/Component/Config/ClientConfig.cs similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/ClientConfig.cs rename to Unity/Assets/Scripts/Component/Config/ClientConfig.cs diff --git a/Unity/Assets/Scripts/Entity/Config/ClientConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/ClientConfig.cs.meta rename to Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta diff --git a/Unity/Assets/Scripts/Component/Config/DBConfig.cs b/Unity/Assets/Scripts/Component/Config/DBConfig.cs new file mode 100644 index 0000000000000000000000000000000000000000..cb9d743e41ff37019101bde02eab22ae896f19dc --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/DBConfig.cs @@ -0,0 +1,11 @@ +using MongoDB.Bson.Serialization.Attributes; + +namespace Model +{ + [BsonIgnoreExtraElements] + public class DBConfig : AConfigComponent + { + public string ConnectionString { get; set; } + public string DBName { get; set; } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Component/Config/DBConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/DBConfig.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..cf7b6069a9ff183ec446d3e0dcbbabb01e5ec3a2 --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/DBConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e8535ccd83c14ff44949812c618f7618 +timeCreated: 1498901248 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Component/Config/HttpConfig.cs b/Unity/Assets/Scripts/Component/Config/HttpConfig.cs new file mode 100644 index 0000000000000000000000000000000000000000..9d10ffbfe8828d31f55202fe90f82e3353c5e7b2 --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/HttpConfig.cs @@ -0,0 +1,13 @@ +using MongoDB.Bson.Serialization.Attributes; + +namespace Model +{ + [BsonIgnoreExtraElements] + public class HttpConfig : AConfigComponent + { + public string Url { get; set; } = ""; + public int AppId { get; set; } + public string AppKey { get; set; } = ""; + public string ManagerSystemUrl { get; set; } = ""; + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Component/Config/HttpConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/HttpConfig.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..a1fd1912e9d828bac6180c06e3bccb1b6fb4f3d1 --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/HttpConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d1dc4ae9437263b4cb6956129ea85149 +timeCreated: 1498901248 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Entity/Config/InnerConfig.cs b/Unity/Assets/Scripts/Component/Config/InnerConfig.cs similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/InnerConfig.cs rename to Unity/Assets/Scripts/Component/Config/InnerConfig.cs diff --git a/Unity/Assets/Scripts/Entity/Config/InnerConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/InnerConfig.cs.meta rename to Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta diff --git a/Unity/Assets/Scripts/Entity/Config/OuterConfig.cs b/Unity/Assets/Scripts/Component/Config/OuterConfig.cs similarity index 89% rename from Unity/Assets/Scripts/Entity/Config/OuterConfig.cs rename to Unity/Assets/Scripts/Component/Config/OuterConfig.cs index 82446c749f6d46e8375a0e5ef54815eacc1ad389..1a0dd48b2cfeeea0bb079170be58fa2eb142d53c 100644 --- a/Unity/Assets/Scripts/Entity/Config/OuterConfig.cs +++ b/Unity/Assets/Scripts/Component/Config/OuterConfig.cs @@ -8,6 +8,8 @@ namespace Model public string Host { get; set; } public int Port { get; set; } + public string Host2 { get; set; } + [BsonIgnore] public string Address { diff --git a/Unity/Assets/Scripts/Entity/Config/OuterConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/OuterConfig.cs.meta rename to Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta diff --git a/Unity/Assets/Scripts/Entity/Config/RunServerConfig.cs b/Unity/Assets/Scripts/Component/Config/RunServerConfig.cs similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/RunServerConfig.cs rename to Unity/Assets/Scripts/Component/Config/RunServerConfig.cs diff --git a/Unity/Assets/Scripts/Entity/Config/RunServerConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/RunServerConfig.cs.meta similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/RunServerConfig.cs.meta rename to Unity/Assets/Scripts/Component/Config/RunServerConfig.cs.meta diff --git a/Unity/Assets/Scripts/Entity/Config/StartConfig.cs b/Unity/Assets/Scripts/Component/Config/StartConfig.cs similarity index 55% rename from Unity/Assets/Scripts/Entity/Config/StartConfig.cs rename to Unity/Assets/Scripts/Component/Config/StartConfig.cs index 1b13f8e9d431a00fbc759a0969edb45f9ffc3a10..22dc456d2072cad2192ac3bf92b96c75940e4a1a 100644 --- a/Unity/Assets/Scripts/Entity/Config/StartConfig.cs +++ b/Unity/Assets/Scripts/Component/Config/StartConfig.cs @@ -1,15 +1,15 @@ -namespace Model +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; + +namespace Model { public class StartConfig: AConfig { public int AppId { get; set; } + [BsonRepresentation(BsonType.String)] public AppType AppType { get; set; } public string ServerIP { get; set; } - - public StartConfig(): base(EntityType.Config) - { - } } } \ No newline at end of file diff --git a/Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/StartConfig.cs.meta similarity index 100% rename from Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta rename to Unity/Assets/Scripts/Component/Config/StartConfig.cs.meta diff --git a/Unity/Assets/Scripts/Component/Config/VersionConfig.cs b/Unity/Assets/Scripts/Component/Config/VersionConfig.cs new file mode 100644 index 0000000000000000000000000000000000000000..a6c41bde869f9af56dcb5fce317ab4b32724bd1b --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/VersionConfig.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using MongoDB.Bson.Serialization.Attributes; +using Newtonsoft.Json; + +namespace Model +{ + public class FileVersionInfo + { + public string File; + public string MD5; + public long Size; + } + + public class VersionConfig : AConfig + { + public int Version; + + [JsonIgnore] + public long TotalSize; + + public List FileVersionInfos = new List(); + + [JsonIgnore] + public Dictionary FileInfoDict = new Dictionary(); + + public override void EndInit() + { + base.EndInit(); + + foreach (FileVersionInfo fileVersionInfo in FileVersionInfos) + { + this.FileInfoDict.Add(fileVersionInfo.File, fileVersionInfo); + this.TotalSize += fileVersionInfo.Size; + } + } + } +} \ No newline at end of file diff --git a/Unity/Assets/Scripts/Component/Config/VersionConfig.cs.meta b/Unity/Assets/Scripts/Component/Config/VersionConfig.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..381bbe76fc6cf249f93a0ce68a31b9af9d3d8d1d --- /dev/null +++ b/Unity/Assets/Scripts/Component/Config/VersionConfig.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2f62876308567a24b83b50edd38fe4c7 +timeCreated: 1498901248 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/Config/AConfig.cs b/Unity/Assets/Scripts/Config/AConfig.cs index a3691c5e36707f2a801b7d0a00cb12f7ee5b13e7..d24f8101344403a88530ed04fd63ec5bed8c9859 100644 --- a/Unity/Assets/Scripts/Config/AConfig.cs +++ b/Unity/Assets/Scripts/Config/AConfig.cs @@ -5,11 +5,11 @@ /// public abstract class AConfig: Entity { - protected AConfig(EntityType entityType): base(entityType) + protected AConfig() { } - protected AConfig(long id, EntityType entityType): base(id, entityType) + protected AConfig(long id): base(id) { } } diff --git a/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs b/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs index 3368ef3ec1b439cb9786ddf3cfd2520172738a5f..30b5531e714ec077133f06cd2c88407f43839a4f 100644 --- a/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs +++ b/Unity/Assets/Scripts/Entity/AssetBundleLoaderAsync.cs @@ -11,7 +11,7 @@ namespace Model private TaskCompletionSource tcs; - public AssetBundleLoaderAsync(AssetBundle assetBundle): base(EntityType.None) + public AssetBundleLoaderAsync(AssetBundle assetBundle) { this.assetBundle = assetBundle; } diff --git a/Unity/Assets/Scripts/Entity/Scene.cs b/Unity/Assets/Scripts/Entity/Scene.cs index 6208899f4960b95905907ef037e346da72e0909e..666f47f6312b61a450c6e73ee9875d1bef93362c 100644 --- a/Unity/Assets/Scripts/Entity/Scene.cs +++ b/Unity/Assets/Scripts/Entity/Scene.cs @@ -21,11 +21,11 @@ public string Name { get; set; } - public Scene(): base(EntityType.Scene) + public Scene() { } - public Scene(long id): base(id, EntityType.Scene) + public Scene(long id): base(id) { } diff --git a/Unity/Assets/Scripts/Entity/WWWAsync.cs b/Unity/Assets/Scripts/Entity/WWWAsync.cs index 8233376a8aa2a0b5d1d4b6bba93d9c17974a86f9..f9c9c41280f6902c86a3a892389e5dbb761c01e4 100644 --- a/Unity/Assets/Scripts/Entity/WWWAsync.cs +++ b/Unity/Assets/Scripts/Entity/WWWAsync.cs @@ -14,10 +14,6 @@ namespace Model public TaskCompletionSource tcs; - public WWWAsync() : base(EntityType.None) - { - } - public float Progress { get diff --git a/Unity/Assets/Scripts/Message/AppType.cs b/Unity/Assets/Scripts/Message/AppType.cs index 274789f665d41aa51b56e4f0157f860d35a24d81..3b5c98bcf32938a76607ce06de3e15800daa28fb 100644 --- a/Unity/Assets/Scripts/Message/AppType.cs +++ b/Unity/Assets/Scripts/Message/AppType.cs @@ -10,13 +10,15 @@ namespace Model Manager = 1, Realm = 2, Gate = 4, + Http = 8, + DB = 16, - Benchmark = 8, - Client = 16, Robot = 32, + Benchmark = 64, + Client = 128, // 7 - AllServer = Manager | Realm | Gate + AllServer = Manager | Realm | Gate | Http | DB } public static class AppTypeHelper diff --git a/Unity/Assets/Scripts/Object/Disposer.cs b/Unity/Assets/Scripts/Object/Disposer.cs index d20df8feab5d681956d74d576388d76c19406ba5..09f631ba35f7892aa7d11b732e2b444a576d8971 100644 --- a/Unity/Assets/Scripts/Object/Disposer.cs +++ b/Unity/Assets/Scripts/Object/Disposer.cs @@ -1,6 +1,8 @@ -namespace Model +using System; + +namespace Model { - public abstract class Disposer: Object + public abstract class Disposer: Object, IDisposable { protected Disposer(): base(IdGenerater.GenerateId()) { @@ -12,7 +14,7 @@ ObjectEvents.Instance.Add(this); } - public override void Dispose() + public virtual void Dispose() { this.Id = 0; } diff --git a/Unity/Assets/Scripts/Object/Entity.cs b/Unity/Assets/Scripts/Object/Entity.cs index 07ec97df7362c3737ebaa915fcca43a4b0f56caf..5b32db5047546d0e8e28b3451df3a054ac4db218 100644 --- a/Unity/Assets/Scripts/Object/Entity.cs +++ b/Unity/Assets/Scripts/Object/Entity.cs @@ -7,8 +7,6 @@ namespace Model { public class Entity: Disposer { - public EntityType Type { get; set; } - [BsonElement] private HashSet components = new HashSet(); @@ -17,17 +15,10 @@ namespace Model protected Entity() { - this.Type = EntityType.None; - } - - protected Entity(EntityType entityType) - { - this.Type = entityType; } - protected Entity(long id, EntityType entityType): base(id) + protected Entity(long id): base(id) { - this.Type = entityType; } public override void Dispose() diff --git a/Unity/Assets/Scripts/Object/Object.cs b/Unity/Assets/Scripts/Object/Object.cs index 6986cd3b362b56c76b44ae41e9002981958b32d2..38abd3cefff59d95d2747bfa9ac046e930acdb1d 100644 --- a/Unity/Assets/Scripts/Object/Object.cs +++ b/Unity/Assets/Scripts/Object/Object.cs @@ -1,8 +1,8 @@ -using System; +using System.ComponentModel; namespace Model { - public abstract class Object: IDisposable + public abstract class Object: ISupportInitialize { public long Id { get; protected set; } @@ -16,7 +16,11 @@ namespace Model this.Id = id; } - public virtual void Dispose() + public virtual void BeginInit() + { + } + + public virtual void EndInit() { } } diff --git a/Unity/Unity.Editor.csproj b/Unity/Unity.Editor.csproj index 92c72599533d3293e851b4995ca1246ddb6534f8..c0f1502005ead868151ff6c98b5ad9bfae6f600e 100644 --- a/Unity/Unity.Editor.csproj +++ b/Unity/Unity.Editor.csproj @@ -107,24 +107,12 @@ Library\UnityAssemblies\UnityEditor.Graphs.dll - - Library\UnityAssemblies\UnityEditor.Android.Extensions.dll - - - Library\UnityAssemblies\UnityEditor.iOS.Extensions.dll - Library\UnityAssemblies\UnityEditor.WindowsStandalone.Extensions.dll Library\UnityAssemblies\SyntaxTree.VisualStudio.Unity.Bridge.dll - - Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll - - - Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll - Assets\JsonDotNet\Assemblies\Standalone\Newtonsoft.Json.dll diff --git a/Unity/Unity.Plugins.csproj b/Unity/Unity.Plugins.csproj index 6164ca605df26f347702b3d53b7f611654e684b7..6567a51aff5b25c0f7166ab15e41fa3bf5199209 100644 --- a/Unity/Unity.Plugins.csproj +++ b/Unity/Unity.Plugins.csproj @@ -74,12 +74,6 @@ Library\UnityAssemblies\UnityEngine.HoloLens.dll - - Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll - - - Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll - Assets\JsonDotNet\Assemblies\Standalone\Newtonsoft.Json.dll diff --git a/Unity/Unity.csproj b/Unity/Unity.csproj index 8024fc4cbf15d33520420b89292a740192136281..b054ce3e606ead2dfd7bc016124cf9a0b6e3e13f 100644 --- a/Unity/Unity.csproj +++ b/Unity/Unity.csproj @@ -12,15 +12,12 @@ {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} .NETFramework v4.6 - - - - + + Game:1 StandaloneWindows64:19 2017.1.0f1 - - + 6 @@ -77,12 +74,6 @@ Library\UnityAssemblies\UnityEngine.HoloLens.dll - - Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll - - - Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll - Assets\JsonDotNet\Assemblies\Standalone\Newtonsoft.Json.dll @@ -436,6 +427,15 @@ + + + + + + + + + @@ -453,12 +453,6 @@ - - - - - - @@ -526,4 +520,4 @@ - \ No newline at end of file +