Exemplo n.º 1
0
        public async Task<bool> SetSettings(Settings settings)
        {
            var argParams = new object[1];
            argParams[0] = settings;
            // TODO : Map the rest of settings
            // https://github.com/hadouken/hadouken/blob/master/js/rpc/webui_setSettings.js
            var response = await SendJsonrpcRequest("webui.setSettings", argParams);

            return response.IsSuccessStatusCode;
        }
Exemplo n.º 2
0
        public async Task<Settings> GetSettings()
        {
            var response = await SendJsonrpcRequest("webui.getSettings");
            var jsonStr = await response.Content.ReadAsStringAsync();
            var jObject = JObject.Parse(jsonStr);
            var settingsRaw = jObject["result"]["settings"];
            // https://github.com/hadouken/hadouken/blob/master/js/rpc/webui_getSettings.js
            var settings = new Settings();

            foreach (var settingRaw in settingsRaw)
            {
                var settingName = (string) settingRaw[0];
                var settingValue = settingRaw[2];

                switch (settingName)
                {
                    case "bind_port":
                        settings.BindPort = (long) settingValue;
                        break;
                    case "conns_globally":
                        settings.ConnectionsLimit = (long) settingValue;
                        break;
                    case "dht":
                        settings.Dht = (bool) settingValue;
                        break;
                    // TODO : Map the rest
                    default:
                        Debug.WriteLine($"{settingName} setting is not mapped");
                        break;
                }
            }

            return settings;
        }