public NRobotService(NRobotServerConfig config)
 {
     if (config == null)
     {
         throw new Exception("No configuration specified");
     }
     _config         = config;
     _keywordManager = new KeywordManager();
     _rpcService     = new XmlRpcService(_keywordManager);
     _httpservice    = new HttpService(_rpcService, _keywordManager, config.Port);
     LoadKeywords();
 }
Example #2
0
        public void TestXmlRpcGetUriTimeout()
        {
            var args = new XmlRpcArg[] { CallerId };

            using var source = new CancellationTokenSource();
            source.Cancel();

            Assert.Catch <OperationCanceledException>(() =>
                                                      XmlRpcService.MethodCall(MasterUri, CallerUri, "getUri", args, source.Token));

            Assert.CatchAsync <OperationCanceledException>(async() =>
                                                           await XmlRpcService.MethodCallAsync(MasterUri, CallerUri, "getUri", args, source.Token));
        }
Example #3
0
        public async Task TestXmlRpcGetUriAsync()
        {
            var args = new XmlRpcArg[] { CallerId };

            using var source = new CancellationTokenSource();
            source.CancelAfter(3000);

            var response = await XmlRpcService.MethodCallAsync(MasterUri, CallerUri, "getUri", args, source.Token);

            Assert.IsTrue(response.TryGetArray(out var responseArray));
            Assert.IsTrue(responseArray.Length == 3);
            Assert.IsTrue(responseArray[0].TryGetInteger(out int successCode) && successCode == 1);
            Assert.IsTrue(responseArray[1].TryGetString(out _));
            Assert.IsTrue(responseArray[2].TryGetString(out string retMasterUri) &&
                          Uri.TryCreate(retMasterUri, UriKind.Absolute, out _));
        }