Example #1
0
 private ObservableCollection <Messenger> LoadRootGeneralMessengers()
 {
     if (ManageViewModel.IsSharingSession == true)
     {
         return(M2qttManager.SharedMessengers);
     }
     return(DatabaseContextUtility.LoadAllGeneralMessenger());
 }
 public static void LoadUnsentLog()
 {
     ActivityLog = DatabaseContextUtility.LoadUnsentActivityLogEntries();
     //If we left some unsent log from the previous use due to the lack of internet connection.
     if (ActivityLog.Any())
     {
         SendActivityLog();
     }
 }
Example #3
0
        public string ShareMessengers()
        {
            if (Client == null || !Client.IsConnected)
            {
                return(MessageIds.NOT_CONNECTED);
            }
            ObservableCollection <Messenger> messengers = DatabaseContextUtility.LoadAllGeneralMessenger();
            //Serialize payload and create wrapper class.
            MqttMessage mqttMessage = new MqttMessage(ApplicationUserName, settings.MessageBrokerUserName, JsonConvert.SerializeObject(messengers), MqttMessageType.MessengerList);
            //Serialize wrapper class.
            string mqttMessageAsJson = JsonConvert.SerializeObject(mqttMessage);

            try
            {
                Client.Publish(settings.Topic, Encoding.UTF8.GetBytes(mqttMessageAsJson), 0, true);
                return(MessageIds.MESSENGERS_SHARED);
            }
            catch {
                return(MessageIds.TECHNICAL_ERROR);
            }
        }