Esempio n. 1
0
        // When the page is constructed, the client receives all pre-existing messages
        // from the database. These messages are loaded into a temporary list which are
        // then read into the ObservableCollection. This intermediary step was made
        // necessary due to the fact that ObservableCollections cannot be assigned to Lists.
        private async void LoadMessages()
        {
            _loadedMessages = await ChatDBService.LoadMessages();

            foreach (var message in _loadedMessages)
            {
                this.LoadedMessages.Add(message);
            }
        }
        // The DB services are initialized with the selected group's information, tying them to the correct locations
        // in Cosmos DB.
        private async void InitializeServices()
        {
            chat  = new ChatDBService();
            flash = new FlashDBService();

            // Initializes the ChangeFeedProcessor.
            await chat.RunChangeFeedHostAsync();

            await flash.RunChangeFeedHostAsync();
        }
        // When the user finishes the quiz, an automated message is generated detailing their efforts.
        private async void FinishQuiz()
        {
            DecideExclamation();

            Message message = new Message()
            {
                ObjType      = "Msg",
                SenderName   = "AnnouncerBot",
                SenderAvatar = new Uri("http://icons.iconarchive.com/icons/danleech/simple/1024/android-icon.png"),
                Text         = MainPageViewModel.CurrentGoogleUsername
                               + " just got " + _correctSubmissions + " out of " + Length
                               + " flashcards right playing " + Creator + "'s " + QuizName
                               + " deck! " + _exclamation,
                Category  = "Announcement",
                Timestamp = DateTime.Now.Ticks.ToString()
            };

            await ChatDBService.UploadMessage(message);

            await _navigationService.GoBackAsync();
        }
Esempio n. 4
0
        public async void ComposeMessage()
        {
            // Disallows the user from publishing empty strings.
            if (Input == null)
            {
                return;
            }

            Message message = new Message()
            {
                ObjType      = "Msg",
                SenderAvatar = MainPageViewModel.CurrentGoogleAvatar,
                SenderName   = MainPageViewModel.CurrentGoogleUsername,
                Text         = Input,
                Category     = PickerCategory,
                Timestamp    = DateTime.Now.Ticks.ToString()
            };

            Input = "";
            await ChatDBService.UploadMessage(message);
        }