public static void Init() { UnityRemoteConsoleSettingData config = UnityRemoteConsoleSettingData.GetCofig(); if (config.autoBoot) { ConsoleToolStart(); } else { Debug.Log("ConsoleBootManager.init"); int state = PlayerPrefs.GetInt(PF_WhenFirstCustomBootThenAutoBoot, 0); if (state == 1) { ConsoleToolStart(); return; } ConsoleBootManager.Init(config, () => { if (config.whenFirstCustomBootThenAutoBoot) { PlayerPrefs.SetInt(PF_WhenFirstCustomBootThenAutoBoot, 1); } ConsoleToolStart(); }); } }
public static bool ConsoleToolStart() { if (isStart) { return(false); } RemoteDeviceInfo deviceInfo = RemoteDeviceInfo.GetLocalDeviceInfo(); UnityRemoteConsoleSettingData config = UnityRemoteConsoleSettingData.GetCofig(); try { string deviceInfoStr = SimpleJsonUtils.ToJson(deviceInfo); LitNetServer.SetNetworkServerManager(deviceInfoStr, config.netPort); LitNetServer.Start(); LoginService loginService = LitNetServer.ServiceManager.Get <LoginService>(); loginService.SetPlayerLoginHandler(new SimplePlayerLoginHandler()); } catch (Exception e) { Debug.LogError(e); return(false); } Debug.Log("LitNetServer.port:" + config.netPort); isStart = true; return(true); }
// Use this for initialization public static void Init(UnityRemoteConsoleSettingData config, Action OnTriggerBoot) { Type[] types = ReflectionTool.GetChildTypes(typeof(BootFunctionBase)); Debug.Log("types.cout:" + types.Length); foreach (var item in types) { object obj = ReflectionTool.CreateDefultInstance(item); if (obj != null) { BootFunctionBase function = (BootFunctionBase)obj; bootFunctions.Add(function); } } foreach (var item in bootFunctions) { try { item.OnInit(config, OnTriggerBoot); } catch (Exception e) { Debug.LogError(e); } } }
public void OnInit(UnityRemoteConsoleSettingData config, Action OnTriggerBoot) { this.config = config; this.OnTriggerBoot = OnTriggerBoot; Debug.Log("KeyboardBootConsole.init"); }
public static void SaveConfig(UnityRemoteConsoleSettingData config) { string json = SimpleJsonUtils.ToJson(config); byte[] keyBytes = Convert.FromBase64String(KeyBase64); string _aesKeyStr = Encoding.UTF8.GetString(keyBytes); json = LiteNetLibManager.AESUtils.AESEncrypt(json, _aesKeyStr); CreateTextFile(SavePathDir + UnityRemoteConsoleSettingData.FileName + ".txt", json); }
public override uint LoginLogic(Login2Server msg, long connectId, out LiteNetLibManager.Player player) { UnityRemoteConsoleSettingData config = UnityRemoteConsoleSettingData.GetCofig(); string key = msg.key; string pw = msg.password; if (config.loginKey.Equals(key) && config.loginPassword.Equals(pw)) { player = new LiteNetLibManager.Player(connectId); player.playerID = Guid.NewGuid().ToString(); return(0); } player = null; return(102); }
public static UnityRemoteConsoleSettingData GetCofig() { if (Application.isPlaying) { if (configData != null) { return(configData); } } TextAsset textAsset = Resources.Load <TextAsset>(FileName); if (textAsset == null || string.IsNullOrEmpty(textAsset.text)) { configData = new UnityRemoteConsoleSettingData(); } else { string json = textAsset.text; try { byte[] keyBytes = Convert.FromBase64String(KeyBase64); string _aesKeyStr = Encoding.UTF8.GetString(keyBytes); json = LiteNetLibManager.AESUtils.AESDecrypt(json, _aesKeyStr); } catch (Exception e) { Debug.LogError(e); } configData = SimpleJsonUtils.FromJson <UnityRemoteConsoleSettingData>(json); if (configData == null) { configData = new UnityRemoteConsoleSettingData(); } } return(configData); }
public void OnInit(UnityRemoteConsoleSettingData config, Action OnTriggerBoot) { this.config = config; this.OnTriggerBoot = OnTriggerBoot; }