ToString() public method

public ToString ( ) : string
return string
Example #1
0
        public async Task GetSettings()
        {
            var dmChannel = await Context.User.GetOrCreateDMChannelAsync();

            ServerSettings settings = _permissionService.GetSettings();

            var builder = EmbedBuilderHelper.GreenBuilder();

            builder.WithTitle("Current Settings:").WithDescription(settings.ToString());

            await dmChannel.SendMessageAsync("", false, builder.Build());
        }
Example #2
0
        public async Task GetSettings()
        {
            var dmChannel = await Context.User.GetOrCreateDMChannelAsync();

            ServerSettings settings = _permissionService.GetSettings();

            var builder = EmbedBuilderHelper.GreenBuilder();


            builder.AddField(x => {
                x.Name     = "Current Settings:";
                x.Value    = settings.ToString();
                x.IsInline = false;
            });

            await dmChannel.SendMessageAsync("", false, builder.Build());
        }
        public async Task <bool> RegisterAsync(CancellationToken cancellationToken = default)
        {
            if (ZooKeeperRegisterServiceConfiguration == null)
            {
                ZooKeeperRegisterServiceConfiguration = new ZooKeeperRegisterServiceConfiguration();
            }

            if (string.IsNullOrWhiteSpace(ZooKeeperRegisterServiceConfiguration.Id))
            {
                ZooKeeperRegisterServiceConfiguration.Id = ServerSettings.ToString();
            }

            if (string.IsNullOrWhiteSpace(ZooKeeperRegisterServiceConfiguration.Name))
            {
                ZooKeeperRegisterServiceConfiguration.Name = ServerSettings.ToString();
            }

            if (string.IsNullOrWhiteSpace(ZooKeeperRegisterServiceConfiguration.Name))
            {
                throw new ArgumentNullException(nameof(ZooKeeperRegisterServiceConfiguration.Name), "Service name value cannot be null.");
            }

            try
            {
                var data = Codec.Serialize(new ZooKeeperNodeInfo
                {
                    Weight    = ServerSettings.Weight ?? 0,
                    Address   = ServerSettings.Address,
                    Port      = ServerSettings.Port,
                    EnableTls = ServerSettings.X509Certificate2 != null
                });
                await CreatePath($"{Root}/{ZooKeeperRegisterServiceConfiguration.Name}/{ZooKeeperRegisterServiceConfiguration.Id}", data);

                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, ex.Message);
                throw;
            }
        }
Example #4
0
    public void LoadFile()
    {
        string serverSettingsPath = Application.dataPath + (Application.isEditor ? "/" : "/../") + "settings.json";

        if (!File.Exists(serverSettingsPath))
        {
            SaveFile();
            return;
        }

        Debug.Log("Loading Server Settings");
        StreamReader reader = new StreamReader(serverSettingsPath);
        string       json   = reader.ReadToEnd();

        Settings = JsonUtility.FromJson <ServerSettings>(json);
        Debug.Log(Settings.ToString());

        // This is here to attempt to get our server's IP address automatically
        if (Settings.IP.ToLower() == "auto")
        {
            string externalIP = new WebClient().DownloadString("http://icanhazip.com");
            Debug.Log("Received Public IP: " + externalIP);
        }
    }
Example #5
0
        private IEnumerator InitAfterFrame()
        {
            yield return(null);

            //ss = PhotonNetwork.field_Public_Static_ServerSettings_0;
            ss = PhotonNetwork.PhotonServerSettings;
            MelonLogger.Msg("ss: " + ss?.ToString() ?? "null");
            MelonLogger.Msg("AppSettings: " + ss?.AppSettings?.ToString() ?? "null");

            defaultServer = ServerDef.CloudServer("VRChat Cloud Server USW", ss.AppSettings.FixedRegion, ss.AppSettings.AppIdRealtime, ss.AppSettings.AppVersion);

            foreach (string text in Environment.GetCommandLineArgs())
            {
                if (text.StartsWith("--photonUseNS="))
                {
                    string value = text.Substring("--photonUseNS=".Length);
                    if (value == "false" || value == "0")
                    {
                        Log("setting UserNameServer to false. Old value was " + ss.AppSettings.UseNameServer);
                        ss.AppSettings.UseNameServer = false;
                    }
                    else if (value == "true" || value == "1")
                    {
                        Log("setting UserNameServer to true. Old value was " + ss.AppSettings.UseNameServer);
                        ss.AppSettings.UseNameServer = true;
                    }
                    else
                    {
                        Log("--photonUseNS was passed with an invalid value");
                    }
                }
                else if (text.StartsWith("--photonFixedRegion="))
                {
                    Log("setting FixedRegion to " + text.Substring("--photonFixedRegion=".Length) + ". Old value was " + ss.AppSettings.FixedRegion);
                    ss.AppSettings.FixedRegion = text.Substring("--photonFixedRegion=".Length);
                }
                else if (text.StartsWith("--photonServer="))
                {
                    Log("setting Server to " + text.Substring("--photonServer=".Length) + ". Old value was " + ss.AppSettings.Server);
                    ss.AppSettings.Server = text.Substring("--photonServer=".Length);
                }
                else if (text.StartsWith("--photonPort="))
                {
                    if (int.TryParse(text.Substring("--photonPort=".Length), out int valueInt))
                    {
                        Log("setting Port to " + valueInt + ". Old value was " + ss.AppSettings.Port);
                        ss.AppSettings.Port = valueInt;
                        Log("Port set to " + ss.AppSettings.Port);
                    }
                    else
                    {
                        Log("--photonPort was passed with an invalid value");
                    }
                }
                else if (text.StartsWith("--photonId"))
                {
                    //Log("setting Id to " + text.Substring("--photonId=".Length) + ". Old value was " + VRCApplicationSetup.field_Private_Static_VRCApplicationSetup_0.gameServerVersionOverride);
                    //VRCApplicationSetup.field_Private_Static_VRCApplicationSetup_0.gameServerVersionOverride = text.Substring("--photonId=".Length);
                    //Log("Id set to " + VRCApplicationSetup.field_Private_Static_VRCApplicationSetup_0.gameServerVersionOverride);
                    Log("setting Id to " + text.Substring("--photonId=".Length) + ". Old value was " + VRCApplicationSetup.Instance.gameServerVersionOverride);
                    VRCApplicationSetup.Instance.gameServerVersionOverride = text.Substring("--photonId=".Length);
                    Log("Id set to " + VRCApplicationSetup.Instance.gameServerVersionOverride);
                }
            }

            MelonLogger.Msg("Waiting for InitUI");

            yield return(null);// InitUI();

            MelonLogger.Msg("Done InitUI");
        }
Example #6
0
        public async Task <bool> RegisterAsync(CancellationToken cancellationToken = default)
        {
            if (ConsulRegisterServiceConfiguration == null)
            {
                ConsulRegisterServiceConfiguration = new ConsulRegisterServiceConfiguration();
            }

            if (string.IsNullOrWhiteSpace(ConsulRegisterServiceConfiguration.Id))
            {
                ConsulRegisterServiceConfiguration.Id = ServerSettings.ToString();
            }

            if (string.IsNullOrWhiteSpace(ConsulRegisterServiceConfiguration.Name))
            {
                ConsulRegisterServiceConfiguration.Name = ServerSettings.ToString();
            }

            if (string.IsNullOrWhiteSpace(ConsulRegisterServiceConfiguration.Name))
            {
                throw new ArgumentNullException(nameof(ConsulRegisterServiceConfiguration.Name), "Service name value cannot be null.");
            }

            Logger.LogTrace("Start registering with consul[{0}]...", ConsulClientConfigure.Address);

            try
            {
                using (var consul = new ConsulClient(conf =>
                {
                    conf.Address = ConsulClientConfigure.Address;
                    conf.Datacenter = ConsulClientConfigure.Datacenter;
                    conf.Token = ConsulClientConfigure.Token;
                    conf.WaitTime = ConsulClientConfigure.WaitTime;
                }))
                {
                    ConsulRegisterServiceConfiguration.Meta = new Dictionary <string, string> {
                        { "X-Tls", (ServerSettings.X509Certificate2 != null).ToString() }
                    };
                    if (ServerSettings.Weight.HasValue)
                    {
                        ConsulRegisterServiceConfiguration.Meta.Add("X-Weight", ServerSettings.Weight.ToString());
                    }

                    //Register service to consul agent
                    var result = await consul.Agent.ServiceRegister(new AgentServiceRegistration
                    {
                        Address           = ServerSettings.Address,
                        Port              = ServerSettings.Port,
                        ID                = ConsulRegisterServiceConfiguration.Id,
                        Name              = ConsulRegisterServiceConfiguration.Name,
                        EnableTagOverride = ConsulRegisterServiceConfiguration.EnableTagOverride,
                        Meta              = ConsulRegisterServiceConfiguration.Meta,
                        Tags              = ConsulRegisterServiceConfiguration.Tags,
                        Check             = new AgentServiceCheck
                        {
                            TCP = ServerSettings.ToString(),
                            DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(20),
                            Timeout  = TimeSpan.FromSeconds(3),
                            Interval = ConsulRegisterServiceConfiguration.HealthCheckInterval
                        }
                    }, cancellationToken);

                    if (result.StatusCode != HttpStatusCode.OK)
                    {
                        Logger.LogError("Registration service failed:{0}", result.StatusCode);
                        throw new ConsulRequestException("Registration service failed.", result.StatusCode);
                    }

                    Logger.LogTrace("Consul service registration completed");
                    return(result.StatusCode == HttpStatusCode.OK);
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e, "Registration service failed:{0}", e.Message);
                return(false);
            }
        }