public void StartForegroundService(int service_port)
        {
            string msg = $"StartForegroundService(port={service_port})";

            Log.Debug(TAG, msg);
            logsDB.AddLogRow(LogStatusesEnum.Info, msg, TAG);

            HttpListenerPort = service_port;
            httpServer.Prefixes.Add($"http://*:{service_port}/");
            httpServer.Start();
            IAsyncResult result = httpServer.BeginGetContext(new AsyncCallback(ListenerCallback), httpServer);
        }
示例#2
0
        public async void StartForegroundService(int foreground_service_port)
        {
            Log.Debug(TAG, $"StartForegroundService(port={foreground_service_port})");

            if (Service == null)
            {
                string msg = "Can't start foreground service. Service is null";
                Log.Error(TAG, msg);
                logsDB.AddLogRow(Model.LogStatusesEnum.Error, msg, TAG);

                return;
            }
            Service.StartForegroundService(foreground_service_port);
        }
示例#3
0
        public async void StartForegroundService(int service_port)
        {
            string msg = $"StartForegroundService(port={service_port})";

            Log.Debug(TAG, msg);
            logsDB.AddLogRow(LogStatusesEnum.Info, msg, TAG);

            MqttBrokerPort = service_port;

            MqttServerOptionsBuilder optionsBuilder = new MqttServerOptionsBuilder()
                                                      .WithDefaultEndpointPort(service_port)
                                                      .WithDefaultEndpointBoundIPAddress(ipAddress)
                                                      .WithDefaultEndpointBoundIPV6Address(IPAddress.None)
                                                      .WithConnectionValidator(MqttConnectionValidator)
                                                      .WithSubscriptionInterceptor(MqttSubscriptionInterceptor)
                                                      .WithApplicationMessageInterceptor(MqttMessageInterceptor);

            await mqttServer.StartAsync(optionsBuilder.Build());
        }
        public void OnServiceDisconnected(ComponentName name)
        {
            string msg = $"OnServiceDisconnected {name.ClassName}";

            Log.Error(TAG, msg);
            logsDB.AddLogRow(Model.LogStatusesEnum.Warn, msg, TAG);

            IsConnected = false;
            Binder      = null;
            myActivity.UpdateUiForStopService();
        }