protected override async Task <ThingState> OnInitAsync() { var port = _gatewaySetupInfo.GatewayType == "HmIp" ? CcuRpcPorts.HomeMaticIp : CcuRpcPorts.HomeMatic; _xmlRpcApi = HomeMaticXmlRpcApiBuilder.Create() .ForUrl($"{_gatewaySetupInfo.Address}:{port}") .Build(); _connection = new CcuConnection(_xmlRpcApi); var xmlRpcServer = new XmlRpcServer(new AspNetCoreHttpServer(), new XmlRpcServerMethods(), Encoding.GetEncoding("iso-8859-1")); xmlRpcServer.Urls.Add("http://homie-workstation:12345/"); _eventServer = new CcuXmlRpcEventServer(xmlRpcServer); _eventServer.RegisterEventHandler(new HomeMaticGatewayEventHandler(_mediator, $"GW_{_gatewaySetupInfo.Id.Gateway}")); await _eventServer.StartAsync(); await _xmlRpcApi.InitAsync("http://homie-workstation:12345/", $"GW_{_gatewaySetupInfo.Id.Gateway}"); return(ThingState.Online); }
private async Task LoadParameterDescriptions(IHomeMaticXmlRpcApi homeMaticXmlRpcApi) { Console.WriteLine("Press key to continue..."); Console.ReadKey(); Console.WriteLine("Starting xml rpc server..."); var httpServer = new AspNetCoreHttpServer { DisableLogging = false, AllowSynchronousIO = true }; var xmlRpcServer = new XmlRpcServer(httpServer) { Encoding = Encoding.GetEncoding("iso-8859-1") }; xmlRpcServer.Urls.Add(XmlRpcUrl); var ccuXmlRpcServer = new CcuXmlRpcEventServer(xmlRpcServer); //var eventReceiver = new CcuEventReceiver(); //eventReceiver.EventMessageTopic // .Register<HomeMaticEventMessage>() // .SubscribeOn(new TaskPoolScheduler(new TaskFactory())) // .Subscribe(msg => Console.WriteLine($"{msg.Address}.{msg.ValueKey} = {msg.Value}")); StartServer(ccuXmlRpcServer, homeMaticXmlRpcApi); Console.ReadKey(); await homeMaticXmlRpcApi.InitAsync("", "TestIntf"); await ccuXmlRpcServer.StopAsync(); }
private void StartServer(CcuXmlRpcEventServer ccuXmlRpcServer, IHomeMaticXmlRpcApi homeMaticXmlRpcApi) { Task.Run(ccuXmlRpcServer.StartAsync); homeMaticXmlRpcApi.InitAsync(XmlRpcUrl, "TestIntf"); }
protected override async ValueTask OnDisposeAsync() { await _xmlRpcApi.InitAsync("", $"GW_{_gatewaySetupInfo.Id.Gateway}"); await _eventServer.StopAsync(); }