LiveMessage
From Facebook Developer Wiki
This feature is currently in beta.
This feature allows developers to send JSON-encoded "messages" directly to a user's browser, via either an API or FBJS call. It can be used, for example, to update a game board without requiring a user to refresh the page. Messages are received via an FBJS callback, and can be handled on both canvas pages and within a profile box (the user must first interact with the profile box, in the latter case).
When registering your FBJS callback, you must specify an "event name", which is a string that identifies which messages your handler is interested in receiving. When sending a message, you also specify an event name, and it will be delivered if a callback has been registered for that event.
Sample Code
To register a callback handler (for receiving messages):
To send a message:
Currently, sending livemessages in FBJS requires registering a callback handler.
To see a complete example in FBJS, check out the LiveMessage Example.
Documentation
- FBJS LiveMessage
- liveMessage.send (API method)
Notes/Limitations
- An app is only allowed to register one callback handler per event name.
- Messages can only be sent and received for users who have signed the TOS for your application.
- LiveMessage is unsupported in IE6. We'll fix that before we take it out of beta.
- Messages can be no longer than 1024 bytes, and event names can be no longer than 128 bytes.
