public static bool ConsoleToolStart() { if (isStart) { return(false); } RemoteDeviceInfo deviceInfo = RemoteDeviceInfo.GetLocalDeviceInfo(); GameConsolePanelSettingConfig config = GameConsolePanelSettingConfig.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); }
public static void SaveConfig(GameConsolePanelSettingConfig config) { string json = SimpleJsonUtils.ToJson(config); byte[] keyBytes = Convert.FromBase64String(KeyBase64); string _aesKeyStr = Encoding.UTF8.GetString(keyBytes); json = AESUtils.AESEncrypt(json, _aesKeyStr); CreateTextFile(SavePathDir + GameConsolePanelSettingConfig.FileName + ".txt", json); }
private string GetDefaultValueString(Type classType, Type parameterType, ParamsDescriptionAttribute paramsDescription) { object value = null; if (paramsDescription != null && !string.IsNullOrEmpty(paramsDescription.getDefaultValueMethodName)) { MethodInfo info = classType.GetMethod(paramsDescription.getDefaultValueMethodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (info != null) { Type returnType = info.ReturnType; if (returnType != parameterType) { Debug.LogError("GetDefaultValueString Method:" + classType.FullName + "." + paramsDescription.getDefaultValueMethodName + " ReturnType(" + returnType.FullName + ") is different from parameterType(" + parameterType + ")"); } else { try { value = info.Invoke(null, new object[0]); } catch (Exception e) { Debug.LogError(e); } } } } if (value == null) { Debug.Log("CreateDefultInstance Type:" + parameterType); value = ReflectionTool.CreateDefultInstance(parameterType); } return(SimpleJsonUtils.ToJson(value)); }
public static void AddInfoValue(string typeName, string label, string key, object value, string description = null) { try { if (string.IsNullOrEmpty(typeName) || string.IsNullOrEmpty(label) || string.IsNullOrEmpty(key)) { Debug.LogError("typeName or label or key cant be null"); return; } if (value == null) { Debug.LogError("value cant be null"); return; } ShowInfoData data = GetShowInfoData(typeName, label, key); string valueStr = SimpleJsonUtils.ToJson(value); string valueTypeStr = value.GetType().FullName; bool isSend = false; if (data == null) { data = new ShowInfoData(); data.typeName = typeName; data.label = label; data.key = key; data.value = valueStr; data.valueTypeStr = valueTypeStr; data.discription = description; infoDatas.Add(data); isSend = true; } else { if (data.valueTypeStr != valueTypeStr) { Debug.LogError(" Path:" + data.GetPath() + " already have value Type:" + data.valueTypeStr + " can not set Value Type:" + valueStr); return; } else { if (data.value != valueStr) { data.value = valueStr; isSend = true; } if (!string.IsNullOrEmpty(description) && data.discription != description) { data.discription = description; isSend = true; } } } if (isSend) { Send2AllPlayer(data); } } catch (System.Exception e) { Debug.LogError(e); } }