/// <summary> /// 异步读取 /// </summary> private IEnumerator ReadAsync(Action <EngineCfg> ReadFinished) { EngineCfg config = null; WWW www = null; string srcPath = null; #if UNITY_IOS srcPath = "file://" + Path.Combine(DeviceInfo.StreamingPath, "Config/Engine.cfg"); #elif UNITY_ANDROID srcPath = Path.Combine(DeviceInfo.StreamingPath, "Config/Engine.cfg"); #endif #if UNITY_EDITOR srcPath = "file:///" + Path.Combine(DeviceInfo.StreamingPath, "Config/Engine.cfg"); #endif www = new WWW(srcPath); yield return(www); byte[] data = www.bytes; using (StreamReader sr = new StreamReader(new MemoryStream(data))) { string wholeTxt = sr.ReadToEnd(); config = JSON.Instance.ToObject <EngineCfg>(wholeTxt); } www.Dispose(); if (ReadFinished != null) { ReadFinished(config); } }
public RealServer(WarInfo war, Action RepBinded, Action PubBinded) { mWar = war; cached = ServerCached.Instance; cached.clear(); RepBindCompleted = RepBinded; PubBindCompleted = PubBinded; monitor = new MonitorClient(); monitor.startMonitor(mWar); EngineCfg engCfg = Core.EngCfg; cached.curServer = new ServerInfo() { IpAddr = "127.0.0.1", PubPort = engCfg.PubPort, PairPort = engCfg.PairPort, HeartBeatPort = engCfg.HeartBeatPort, ServerName = "Allen", ServerID = DeviceInfo.GUID, }; publisher = new PubServer(war, PubBindCompleted); Resper = new ResponseServer(war, HandleMQMsg, RepBindCompleted); type = GetType(); c_bf = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance; cmdMethod = new Dictionary <string, MethodInfo>(); cachedMethod(); proxyCli = new ProxyClient(-1, publisher); }
static int Initialize(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); EngineCfg arg0 = LuaScriptMgr.GetNetObject <EngineCfg>(L, 1); Core.Initialize(arg0); return(0); }
/// <summary> /// Initialize this instance. /// We must follow special sequnce. /// 仅且仅初始化一次 /// </summary> public static void Initialize(EngineCfg cfg) { ConsoleEx.DebugLog("Core Engine is initializing ....", ConsoleEx.YELLOW); //Initial sequnce DevFSM = DeviceFSM.Instance; GameFSM = GamePlayFSM.Instance; EngCfg = cfg; if (GameFSM.InitOK == Consts.FAILURE) { //Have one NetMQContext ONLY. This will be used to created ALL sockets within the process. ZeroMQ = NetMQContext.Create(); //DataPersisteManager should be initialize first. and tell the non-account path DPM = LocalIOManager.getInstance(DeviceInfo.PersistRootPath); //Unity UI Basically Manager EntityMgr = new EntityManager(); //Timer should run. TimerEng = new TimerMaster(); //Sound manager. SoundEng = SoundEngine.GetSingleton(); //EventCenter must initialize later than Network Engine NetEng = new NetworkEngine(); //EventCenter also must initialize later than Aysnc Engine AsyncEng = AsyncTask.Current; //Coroutine Coroutine = CoroutineProvider.Instance(); EVC = new EventCenter(NetEng.httpEngine, NetEng.SockEngine, EntityMgr); ResEng = new Loader(); Data = new DataCore(); //register some vars. CoreParam(); } else { //TODO: 此分支是初始化一次OK后,注销之后进入的分支情况 } RegisterInterface(); ConsoleEx.DebugLog("Core Engine is initialized ....", ConsoleEx.YELLOW); GameFSM.OnInitOk(); }
public BaseSsock(WarInfo war) { warInfo = war; EngCfg = Core.EngCfg; }
void ReadFinished(EngineCfg cfg) { ConsoleEx.DebugLog("---Read Engine Configure Finished ----"); Application.targetFrameRate = cfg.FrameRate; Core.Initialize(cfg); }