using DeepCore; using DeepCrystal.RPC; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DeepMMO.Server { public static partial class ServerNames { public const string GateServerType /* */ = "GateServer"; public const string ConnectServerType /* */ = "ConnectServer"; public const string SessionServiceType /**/ = "SessionService"; public const string AreaManagerType /* */ = "AreaManager"; public const string AreaServiceType /* */ = "AreaService"; public const string LogicServiceType /* */ = "LogicService"; public const string RankingServiceType /* */ = "RankingService"; public const string LogServiceType = "LogService"; //日志服务器 public const string GuildServiceType = "GuildService"; public static RemoteAddress LogService = new RemoteAddress("LogService", null, LogServiceType); public static RemoteAddress GateServer = new RemoteAddress("GateServer", null, GateServerType); public static RemoteAddress ConnectServer = new RemoteAddress("Connect:", null, ConnectServerType); public static RemoteAddress SessionService = new RemoteAddress("Session:", null, SessionServiceType); public static RemoteAddress AreaManager = new RemoteAddress("AreaManager", null, AreaManagerType); public static RemoteAddress AreaService = new RemoteAddress("Area:", null, AreaServiceType); public static RemoteAddress LogicService = new RemoteAddress("Logic:", null, LogicServiceType); public static RemoteAddress RankingService = new RemoteAddress("RankingService", null, RankingServiceType); public static RemoteAddress GuildService = new RemoteAddress("GuildService", null, GuildServiceType); public const string SessionPrefix = "Session:"; public const string ConnectPrefix = "Connect:"; public const string LogicPrefix = "Logic:"; public const string AreaPrefix = "Area:"; public static RemoteAddress CreateSessionServiceAddress(string accountID, RemoteAddress connectServer) { return new RemoteAddress(SessionPrefix + accountID, connectServer.ServiceNode, SessionService.ServiceType); } //动态创建场景管理器 public static Task GetOrCreateAreaManagerServiceAsync(this IService prv, string GID) { var cfg = new HashMap(); cfg["groupID"] = GID; int groupId = Convert.ToInt32(GID); if (groupId>1000) { throw new Exception("服务器组ID 过大:"+groupId); } return prv.Provider.GetOrCreateAsync(new RemoteAddress(AreaManager.ServiceType + ":" + GID, prv.SelfAddress.ServiceNode, AreaManager.ServiceType), cfg); //var cfg = new HashMap(); //cfg["groupID"] = GID; //return prv.Provider.GetOrCreateAsync(new RemoteAddress(AreaService.ServiceType + ":" + GID, prv.SelfAddress.ServiceNode, AreaService.ServiceType), cfg); } //动态创建场景服务器 public static Task GetOrCreateAreaServiceAsync(this IService prv, string GID) { var cfg = new HashMap(); cfg["groupID"] = GID; return prv.Provider.GetOrCreateAsync(new RemoteAddress(AreaService.ServiceType + ":" + GID, prv.SelfAddress.ServiceNode, AreaService.ServiceType), cfg); //var cfg = new HashMap(); //cfg["groupID"] = GID; //return prv.Provider.GetOrCreateAsync(new RemoteAddress(AreaService.ServiceType + ":" + GID, prv.SelfAddress.ServiceNode, AreaService.ServiceType), cfg); } /// /// 获取逻辑服务地址 /// /// /// public static RemoteAddress GetLogicServiceAddress(string roleID, string logicNode = null) { return new RemoteAddress(LogicPrefix + roleID, logicNode, LogicService.ServiceType); } } }