Documentation
This document contains more in-depth documentation not covered in the quick introduction or installation instructions.
The options
object
The function Messenger.Create
takes an object with options as its third argument. The following options are available:
Name | Type | Description |
---|---|---|
dispatch | function | Specifies the callback function to call when a message is received.
|
census | function | Specifies the callback function to call when a new census (number of people connected) is received. A census is always received when the connection is established, and a new one is gathered at regular intervals after that.
|
feedback | boolean | Specifies that the messages you send should be dispatched to the function specified in the dispatch option. This can be convenient sometimes. Default is that your own messages are not dispatched. The callback to the dispatch function will be made at the time when the message is sent. |
immediateFeedback | boolean | Specifies that the feedback of messages you send should be done immediately when the send function is called, and not at the time when the message is sent. |
initial | integer | The number of old messages to get initially, i.e. when the connection to the server is established. Default is specified on the server (default is 10). |
error | function | Callback function to call when an internal error occurs. Useful only for debugging. Parameter is a string. error: alert will display the error as an alert. |
maxAge | integer | The maximum age in seconds of initial messages, i.e. messages fetched when the connection is established. Default is specified on the server (default is 7 days). If you're only interested in recent messages, it makes sense to set this low. |
scriptFileName | string | Specifies the name of the script on the server. Default is "message.php". |
shortUrls | boolean | Specifies that the URLs to access on the server are in the form "/directory/service/action" instead of the default "/directory/message.php?service=service&action=action", which is, arguably, more web 2.0. You can use the .htaccess file supplied in the zip to enable this on the server side. |