#29 Enhance chat template for minimal HDD access

closed
Steve Davies
5
2012-09-17
2012-09-17
Steve Davies
No

There is a requirement to be able to poll the Chat rooms/messages data on a regular bases (1 query per second per user) while not impacting database or disk access too much. The current model could be simply extended to support this by adding a memory-only query of active rooms eg:
rb.chat.getActive(contact_id); // contact_id of -1 for all rooms

As a secondary feature it would be useful for rooms to auto-cleanup if they are idle so that if a room has no-one joined or linked, it will be auto-purged after a specified period.

Discussion

  • Steve Davies
    Steve Davies
    2012-09-17

    Patch applied/checked in adds rb.chat.getActive() method which should allow a chat-client page enough information to know whether a call to rb.chat.poll() is necessary

    ie. provides highest msgID and last poll time. Last poll time allow periodic poll to prevent inactivity timeout. msgID allows instant poll if a new message has arrived. Some of the provided data may seem redundant, but comes straight from RAM, and is useful for a specifc use-case.

    Optional "Autoclean" (num seconds) parameter added on room creation. This option only applies if it does not contradict any existing settings, such as archive flag. It causes any room that is unjoined and unlinked for all contacts to be cleaned-up after the specified timeout. It also implies an instant-cleanup if the final un-link or un-join command is executed in a page, rather than being a timeout event itself.

     
  • Steve Davies
    Steve Davies
    2012-09-17

    This change should have no impact on existing implementations as all existing behaviours will be unchanged if no new commands or parameters are used.

    There is a known optimisation possible in this code - At present the getActive(id) and getActive(-1) methods use 2 virtually identical code paths. The getActive(id) code path could be optimised by using a map/hash lookup, but at present it scans all rooms in RAM.

    So far it is quick enough to cause no issue.

     
  • Steve Davies
    Steve Davies
    2012-09-17

    • status: open --> closed