Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-56139

Message area should update with ajax rather than page reload

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      General Test

      1. Create a site with at least two users on it that have no messages at all
      2. Log in as a user and navigate to the messaging page (user menu > messages)
      3. Make sure there are no errors in the developer console in the browser when the messaging area has no message
      4. Send a message to the other user
      5. Log in as the other user in a separate browser
      6. Send messages back and forth between each user, the messaging area should automatically update with the new messages between each user (there can be a small time delay for the update)

      Polling Back Off Test

      The polling is using a timeout that backs off over time if no messages are received from the check. As soon as a result is returned (or a new conversation selected) the timeout is reset back to the start (increased frequency).

      You can check the back off by viewing the network tab in the browser's developer tools and watch the requests for 'message_area_messages' become less and less frequent over time.

      Open your config.php file and edit the following $CFG->messagingminpoll, $CFG->messagingmaxpoll and $CFG->messagingtimeoutpoll ensure they are obeyed.

      1. messagingminpoll - The minimum time to poll. Eg. if this is set to '10' then it will poll a minimum of every 10 seconds (this will increment by 1 each time a message is not found).
      2. messagingmaxpoll - The maximum time to poll. Eg. if this is set to '120' then it will poll a maximum of 2 minutes until a message is received (then it will reset).
      3. messagingtimeoutpoll - The maximum timeout to poll. Eg. if this is set to '300' then once the 'messagingmaxpoll' has been reached it will then poll every 5 minutes until a message is received.

      Cache Test

      The timecreated value of the most recent message sent between each user is cached so that if we're requesting messages for sometime after that value we know there will be no results and we can avoid a DB call.

      To test this you can load the messaging page and give it a second or two to warm the cache and then a die() statement in the get_messages function after the cache check at around line 310 of message/classes/api.php.

      Then check your networks tab for your browser's developer tools and make sure the 'message_area_messages' requests are still returning correctly (because they should be returning because your die statement due to the cache).

      Show
      General Test Create a site with at least two users on it that have no messages at all Log in as a user and navigate to the messaging page (user menu > messages) Make sure there are no errors in the developer console in the browser when the messaging area has no message Send a message to the other user Log in as the other user in a separate browser Send messages back and forth between each user, the messaging area should automatically update with the new messages between each user (there can be a small time delay for the update) Polling Back Off Test The polling is using a timeout that backs off over time if no messages are received from the check. As soon as a result is returned (or a new conversation selected) the timeout is reset back to the start (increased frequency). You can check the back off by viewing the network tab in the browser's developer tools and watch the requests for 'message_area_messages' become less and less frequent over time. Open your config.php file and edit the following $CFG->messagingminpoll, $CFG->messagingmaxpoll and $CFG->messagingtimeoutpoll ensure they are obeyed. messagingminpoll - The minimum time to poll. Eg. if this is set to '10' then it will poll a minimum of every 10 seconds (this will increment by 1 each time a message is not found). messagingmaxpoll - The maximum time to poll. Eg. if this is set to '120' then it will poll a maximum of 2 minutes until a message is received (then it will reset). messagingtimeoutpoll - The maximum timeout to poll. Eg. if this is set to '300' then once the 'messagingmaxpoll' has been reached it will then poll every 5 minutes until a message is received. Cache Test The timecreated value of the most recent message sent between each user is cached so that if we're requesting messages for sometime after that value we know there will be no results and we can avoid a DB call. To test this you can load the messaging page and give it a second or two to warm the cache and then a die() statement in the get_messages function after the cache check at around line 310 of message/classes/api.php. Then check your networks tab for your browser's developer tools and make sure the 'message_area_messages' requests are still returning correctly (because they should be returning because your die statement due to the cache).
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-56139_master

      Description

      When viewing a conversation in the message area we should do an ajax request for new messages in the background and update the page if there are any, rather than just waiting for the user to reload the whole page.

      The request frequency to back off over time to ensure we aren't spamming the server. E.g. wait 5 seconds and check, if no results then wait 10 seconds, if no results then wait 30 etc. If you get results at any point it can reset the frequency.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  5/Dec/16