FBJS LiveMessage

From Facebook Developers Wiki

Jump to: navigation, search

This feature is currently in beta.

This is the FBJS documentation for LiveMessage. You should already be familiar with FBJS and LiveMessage before reading this.

[edit] Constructor

LiveMessage(event_name, callback_fn) 
Initializes a LiveMessage object.
event_name - Name of the "event" that messages will be sent and received with.
callback_fn - Function that will be called when a message is received.
Parameters:
data - The received message.


[edit] Object Methods

send(recipient, message) 
Sends a message with the event name specified in the constructor.
recipient - User ID of the recipient.
message - Message to send. This can be any javascript object.
setSendSuccessHandler(callback_fn) 
Registers a callback to be called when a message is sent.
callback_fn - Function that will be called when a message successfully sent.
Parameters:
recipient - User ID of the recipient.
data - The sent message.
setSendErrorHandler(callback_fn) 
Registers a callback to be called when a message failed to send.
callback_fn - Function that will be called when a message could not be sent.
Parameters:
error_code - Error code.
error_message - Description of the error that occurred.
recipient - User ID of the recipient.
data - The message that could not be sent.
setShutdownHandler(callback_fn) 
Registers a callback to be called when the LiveMessage system has a critical error.
callback_fn - Function that will be called the LiveMessage system has been shut down. Perhaps the user should refresh the page.
Parameters: None.
setRestartHandler(callback_fn) 
Registers a callback to be called when the LiveMessage system has recovered from a shutdown.
callback_fn - Function that will be called the LiveMessage system has recovered from a shutdown.
Parameters: None.