// Use this for initialization
        public static void Init(URCSettingData 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(URCSettingData config, Action OnTriggerBoot)
        {
            this.config        = config;
            this.OnTriggerBoot = OnTriggerBoot;

            Debug.Log("KeyboardBootConsole.init");
        }
        public static void SaveConfig(URCSettingData config)
        {
            string json = SimpleJsonUtils.ToJson(config);

            byte[] keyBytes   = Convert.FromBase64String(KeyBase64);
            string _aesKeyStr = Encoding.UTF8.GetString(keyBytes);

            json = SimpleNetManager.AESUtils.AESEncrypt(json, _aesKeyStr);
            CreateTextFile(SavePathDir + URCSettingData.FileName + ".txt", json);
        }
Exemple #4
0
        public override uint LoginLogic(Login2Server msg, Session session, out SimpleNetManager.Player player)
        {
            URCSettingData config = URCSettingData.GetCofig();

            string key = msg.key;
            string pw  = msg.password;


            if (config.loginKey.Equals(key) && config.loginPassword.Equals(pw))
            {
                player          = new SimpleNetManager.Player(session);
                player.playerID = Guid.NewGuid().ToString();

                return(0);
            }
            player = null;
            return(102);
        }
        public static URCSettingData GetCofig()
        {
            if (Application.isPlaying)
            {
                if (configData != null)
                {
                    return(configData);
                }
            }

            TextAsset textAsset = Resources.Load <TextAsset>(FileName);

            if (textAsset == null || string.IsNullOrEmpty(textAsset.text))
            {
                configData = new URCSettingData();
            }
            else
            {
                string json = textAsset.text;
                try
                {
                    byte[] keyBytes   = Convert.FromBase64String(KeyBase64);
                    string _aesKeyStr = Encoding.UTF8.GetString(keyBytes);
                    json = SimpleNetManager.AESUtils.AESDecrypt(json, _aesKeyStr);
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
                configData = SimpleJsonUtils.FromJson <URCSettingData>(json);
                if (configData == null)
                {
                    configData = new URCSettingData();
                }
            }

            return(configData);
        }
Exemple #6
0
        public static bool ConsoleStart()
        {
            Init();

            if (isStart)
            {
                return(false);
            }

            RemoteDeviceInfo deviceInfo = RemoteDeviceInfo.GetLocalDeviceInfo();

            deviceInfo.otherData.Add("ServerVersion", ServerVersionInfo.Version);
            deviceInfo.otherData.Add("MinClientVersion", ServerVersionInfo.MinClientVersion);

            URCSettingData config = URCSettingData.GetCofig();

            try
            {
                string deviceInfoStr = SimpleJsonUtils.ToJson(deviceInfo);
                NetServer.Start(config.netPort);
                NetServer.DiscoverServer.Start(config.netPort, deviceInfoStr);

                LoginService loginService = NetServer.ServiceManager.Get <LoginService>();
                loginService.SetPlayerLoginHandler(new SimplePlayerLoginHandler());

                //LogService logService = NetServer.ServiceManager.Get<LogService>();
                //logService.logSwitchForceControl = logSwitchForceControl;
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                return(false);
            }

            Debug.Log("URC NetServer.port:" + config.netPort);
            isStart = true;
            return(true);
        }
Exemple #7
0
 public void OnInit(URCSettingData config, Action OnTriggerBoot)
 {
     this.config        = config;
     this.OnTriggerBoot = OnTriggerBoot;
 }