| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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:<Number>", null, ConnectServerType);
- public static RemoteAddress SessionService = new RemoteAddress("Session:<AccountID>", null, SessionServiceType);
- public static RemoteAddress AreaManager = new RemoteAddress("AreaManager", null, AreaManagerType);
- public static RemoteAddress AreaService = new RemoteAddress("Area:<Number>", null, AreaServiceType);
- public static RemoteAddress LogicService = new RemoteAddress("Logic:<RoleID>", 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<IRemoteService> GetOrCreateAreaManagerServiceAsync(this IService prv, string GID)
- {
- var cfg = new HashMap<string, string>();
- 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<string, string>();
- //cfg["groupID"] = GID;
- //return prv.Provider.GetOrCreateAsync(new RemoteAddress(AreaService.ServiceType + ":" + GID, prv.SelfAddress.ServiceNode, AreaService.ServiceType), cfg);
- }
- //动态创建场景服务器
- public static Task<IRemoteService> GetOrCreateAreaServiceAsync(this IService prv, string GID)
- {
- var cfg = new HashMap<string, string>();
- cfg["groupID"] = GID;
- return prv.Provider.GetOrCreateAsync(new RemoteAddress(AreaService.ServiceType + ":" + GID, prv.SelfAddress.ServiceNode, AreaService.ServiceType), cfg);
- //var cfg = new HashMap<string, string>();
- //cfg["groupID"] = GID;
- //return prv.Provider.GetOrCreateAsync(new RemoteAddress(AreaService.ServiceType + ":" + GID, prv.SelfAddress.ServiceNode, AreaService.ServiceType), cfg);
- }
- /// <summary>
- /// 获取逻辑服务地址
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- public static RemoteAddress GetLogicServiceAddress(string roleID, string logicNode = null)
- {
- return new RemoteAddress(LogicPrefix + roleID, logicNode, LogicService.ServiceType);
- }
- }
- }
|