====== onChatMessage() ======
wrtc.onChatMessage() is an event function called when a chat message is received.
You must write your own wrtc.onChatMessage() function to be able to display received chat messages.
===== Arguments =====
wrtc.onChatMessage(msg)
* msg - JSON structure containing received chat message: {type:"chat", from:..., from_dn:..., to:..., format:..., msg:...}
* from - address message was sent from eg "john.doe@company.com"
* from_dn - (optional, may be missing) display name of person sending you the message eg "John Doe"
* to - the address the message was sent to (your address)
* format - message format:
* "text/plain" - text message
* "iscomposing" - the person at fraddr has started to type an answer to you
* messages received from SIP clients may have other message formats too
* msg - the received message text
===== Return value =====
Ignored.
===== Example =====
{type:"chat", from:"john.doe@company.com", from_dn:"John Doe", to:"foo@company.com", format:"text/plain", msg:"Hello!"} \\
{type:"chat", from:"foo@company.com", to:"john.doe@company.com", format:"iscomposing", msg:""}
wrtc.onChatMessage = function(msg) {
if (msg.format == "iscomposing")
-- display someone is composing an answer to you --
else
-- display received msg.msg --
}
===== See Also =====
[[ixnx:wrtc:js:api:wrtc:sendchatmessage|wrtc.sendChatMessage()]]
[[ixnx:wrtc:js:api:wrtc:onchatmessageerror|wrtc.onChatMessageError()]]