Example #1
0
        public static void Main(string[] args)
        {
            VisionChannel = new VisionChannel1()
            {
                AttentionLevel               = AttentionLevel.deepDetail,
                DisplayFilterMinLevel        = AttentionLevel.deepDetail,
                DisplayedLogMessagesMaxCount = 1000,
                ClearLog_RamSizeMB           = 100,
                ClearLog_MessagesCount       = 1000,
            };
            VisionChannel.SevereMessageEmitted += (msg) => Console.WriteLine(msg.Message);

            try
            {
                VisionChannel.Emit("", "", AttentionLevel.higherLevelDetail, "creating user app");
                UserAppEngine = new UserAppEngine(UserAppConfiguration.Default, VisionChannel);
                VisionChannel.Emit("", "", AttentionLevel.higherLevelDetail, $"creating web host at {Url}");
                var host = CreateHostBuilder(Url, args).Build();
                VisionChannel.Emit("", "", AttentionLevel.higherLevelDetail, $"created web host at {Url}");

                Console.WriteLine($"please access messenger web UI from same machine in browser: {Url}");

                VisionChannel.Emit("", "", AttentionLevel.higherLevelDetail, $"running web host at {Url}");
                host.Run();
                UserAppEngine?.Dispose();
            }
            catch (Exception exc)
            {
                VisionChannel.Emit("", "", AttentionLevel.strongPain, $"error in Program.Main(): {exc}");
                UserAppEngine?.Dispose();
            }
        }
Example #2
0
 public App(UserAppEngine userAppEngine, VisionChannel1 visionChannel)
 {
     InitializeComponent();
     DependencyService.Register <MockDataStore>();
     MainPage = new MainPage(userAppEngine, visionChannel);
 }
Example #3
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (intent.Action.Equals(ACTION_START_SERVICE))
            {
                if (_userAppEngine != null)
                {
                    //  Log.Info(TAG, "OnStartCommand: The service is already running.");
                }
                else
                {
                    //  Log.Info(TAG, "OnStartCommand: The service is starting.");
                    //   RegisterForegroundService();
                    //   handler.PostDelayed(runnable, Constants.DELAY_BETWEEN_LOG_MESSAGES);
                    //   isStarted = true;

                    var config = UserAppConfiguration.Default;
                    config.DatabaseBasePathNullable = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                    _userAppEngine = new UserAppEngine(config, _visionChannel);
                    _visionChannel.SevereMessageEmitted += (errorMsg) =>
                    {
                        Android.Util.Log.Error("Dcomms", errorMsg.Message);
                    };

                    if (NewAndroidApiVersion)
                    {
                        var channel = new NotificationChannel(CHANNEL_ID, "Dcomms messengerA", NotificationImportance.Default)
                        {
                            Description = "Dcomms messengerA"
                        };
                        var notificationManager = (NotificationManager)GetSystemService(NotificationService);
                        notificationManager.CreateNotificationChannel(channel);
                    }

                    var notification = (NewAndroidApiVersion ? new Notification.Builder(this, CHANNEL_ID) : new Notification.Builder(this))
                                       .SetContentTitle("Dcomms messengerA")
                                       .SetContentText("Dcomms messengerA")
                                       .SetSmallIcon(Resource.Drawable.xamarin_logo// ic_stat_name
                                                     )
                                       .SetContentIntent(BuildIntentToShowMainActivity())
                                       .SetOngoing(true)
                                       //    .AddAction(BuildRestartTimerAction())
                                       //    .AddAction(BuildStopServiceAction())
                                       .Build();



                    // Enlist this instance of the service as a foreground service
                    StartForeground(SERVICE_RUNNING_NOTIFICATION_ID, notification);


                    foreach (var cb in _startServiceCallbacks)
                    {
                        try
                        {
                            cb(_userAppEngine, _visionChannel);
                        }
                        catch
                        {
                        }
                    }
                    _startServiceCallbacks.Clear();
                }
            }
            //else if (intent.Action.Equals(Constants.ACTION_STOP_SERVICE))
            //{
            //    Log.Info(TAG, "OnStartCommand: The service is stopping.");
            //    timestamper = null;
            //    StopForeground(true);
            //    StopSelf();
            //    isStarted = false;

            //}
            //else if (intent.Action.Equals(Constants.ACTION_RESTART_TIMER))
            //{
            //    Log.Info(TAG, "OnStartCommand: Restarting the timer.");
            //    timestamper.Restart();

            //}

            // This tells Android not to restart the service if it is killed to reclaim resources.
            return(StartCommandResult.Sticky);
        }
Example #4
0
 public MainPage(UserAppEngine userAppEngine, VisionChannel1 visionChannel)
 {
     InitializeComponent();
     this.BindingContext = userAppEngine;
     VisionChannelPage.BindingContext = visionChannel;
 }