Fileref:mod/chat/sl webintercom linker.php

From SLIS Second Life Wiki

Jump to: navigation, search

Image:folder.gif (parent)

This Linker Script allows the Sloodle WebIntercom object in Second Life to communicate with Moodle chatrooms. There are 3 modes of operation: selection mode fetches a list of chatrooms in a particular course, listen mode fetches a list of recent chat messages in the chatroom, and chat mode will send a new message to the chatroom. (Note: chat mode implicitly falls through to listen mode after a message has been written to the chatroom).

By default, the script behaves in selection mode, unless the parameters for other modes are specified.


Contents

Additional Information

Debug mode will output additional data, indicating what is happening at all points in the script.


Dependencies

Sloodle files:


Request Parameters

The following parameters are always required:

  • sloodlepwd = the Prim Password used to authenticate the WebIntercom for this site
  • sloodlecourseid = ID of the course which the request relates to


The following additional parameter is required for listen and chat modes:

  • sloodlemoduleid = course module instance ID of the desired chatroom


The following additional parameters are also required for chat mode:

  • sloodleuuid = the SL UUID of the agent chatting (optional if 'sloodleavname' is specified)
  • sloodleavname = the name of the agent chatting (optional if 'sloodleuuid' is specified)
  • sloodlechatmsg = a string containing the chat message to be written


The following parameter is always optional:

  • sloodledebug = activates debug mode


Response

Selection Mode

In selection mode, the script returns a status code 1 if at least one available (i.e. visible) chatroom was found in the course. Each line of data contains information about a single chatroom, in the following format:

<moduleid>|<name>

<moduleid> is an integer containing the course module instance ID of the chatroom (which must be passed back to the linekr script in parameter 'sloodlemoduleid' for listen/chat modes). <name> is a string containing the name of the chatroom.


If no available chatrooms were found in the specified course, then the status code will be -601, and the data line should contain an error message. If you definitely have at least one chatroom in your course, but you still get error -601, then make sure your course is visible, the chatrooms are visible, and that they are not limited to certain groups.

Note: other error codes may also be given in other circumstances, such as the course not being found, or the Prim Password failing.

Listen Mode

If successful in listen mode, the status code will be 1, and each data line will contain a recent chat message from the chatroom. The format of each line will be as follows:

<msgid>|<chattername>|<msg>

The <msgid> is an integer giving the database identifier of the message (this value increments for every message, allowing the WebIntercom to ignore any messages it might have seen before). <chattername> is a string containing the name of the person who chatted the message (this will be the full name of the user according to their Moodle profile, if they are registered, or "Guest User" if not).

The <msg> string contains the chat message, and will typically being with "(SL)" if it was posted from within Second Life, allow the WebIntercom to ignore any messages which in-world users would already have seen.

Chat Mode

If successful, chat mode behaves exactly like listen mode. However, the insertion of new chat messages into the chatroom happens before the script falls-through to listen mode, so if an error occurs in chat mode, then one of the standard error status codes will be returned, and the data line should be an error message.


Algorithm

  1. Construct SloodleLSLHandler object
  2. Process basic request data
  3. Authenticate request
  4. Fetch additional parameters
  5. Find requested course (terminate on failure)
  6. Has module ID been omitted? If yes then enter selection mode:
    1. Get list of available chatrooms (terminate on failure)
    2. Iterate through chatrooms and output each one
    3. Render response
    4. Terminate script
  7. If module
  8. Fetch chatroom instance (terminate on failure)
  9. Has a chat message been specified? If yes then enter chat mode:
    1. Is avatar registered with Moodle site? If yes then:
      1. Login user to site
    2. Else:
      1. Login as guest user
    3. Clean the chat message (make it safe for database insertion)
    4. Construct database record object for chat message
    5. Insert record into database (terminate on failure)
    6. (Falling-through to listen mode)
  10. Query for chat messages which have occurred in the last minute
  11. Iterate through messages and output each one
  12. Render response
  13. Terminate script


This page is part of the Sloodle documentation
SloodleDocs Home | User Documentation | Administrator Documentation | Developer Documentation | Sloodle Wiki Home