...
Code Block | ||
---|---|---|
| ||
LIVECHATSDK.LIVECHAT.joinContact("CHAT_eaa2e7c0-9c26-40db-b720-d777ab68078d", "John Doe").then(
function (contact) {
console.log("[CTLive] Contact JOINED", contact);
// Store the contact instance in a custom Hashmap
MY_ACTIVE_CHAT[contact.contact.id] = contact;
// Bind 'message' event custom callback
contact.on("message",
function (event) {
var DOMObj = null;
console.log("[CTLIVE] On [message] event");
console.log("Nickname......" + event.content.user.nickname);
console.log("Text.........." + event.content.text);
console.log("Is Agent......" + event.content.user.isAgent);
console.log("Msg ID........" + event.id);
}
);
// Bind 'message' event custom callback
contact.on("messageReceived",
function (event) {
console.log("[CTLIVE] On [messageReceived] event");
console.log("Msg ID........" + event.messageID);
}
);
// Bind 'messageSeen' event custom callback
contact.on("messageSeen",
function (event) {
console.log("[CTLIVE] On [messageSeen] event");
console.log("Msg ID........" + event.messageID);
}
);
// Bind 'multimediaMessage' event custom callback
contact.on("multimediaMessage",
function (event) {
console.log("[CTLIVE] On [multimediaMessage] event");
if ( event.messageType === "IMAGE" ) {
console.log("Caption............" + event.content.caption);
console.log("Is Agent..........." + event.content.user.isAgent);
console.log("User Nickname......" + event.content.user.nickname);
console.log("User ID............" + event.content.user.id);
console.log("Chat ID............" + contact.contact.id);
console.log("Msg ID............." + event.id)
console.log("Content (Base64)..." + event.content.img);
}
if ( event.messageType === "DOCUMENT" ) {
console.log("File Extension.....", event.content.documentType);
// PDF, DOC; DOCX, PPT, PPTX, XLS, XLSX
console.log("File Caption.......", event.content.caption);
console.log("Is Agent..........." + event.content.user.isAgent);
console.log("User Nickname......" + event.content.user.nickname);
console.log("User ID............" + event.content.user.id);
console.log("Chat ID............" + contact.contact.id);
console.log("Msg ID............." + event.id)
console.log("Content (Base64)..." + event.content.document);
}
}
);
// Bind 'link' event custom callback
contact.on("link",
function (event) {
console.log("[CTLIVE] On [link] event");
console.log("URL................", event.content.url);
console.log("Is Agent..........." + event.content.user.isAgent);
console.log("User Nickname......" + event.content.user.nickname);
console.log("User ID............" + event.content.user.id);
console.log("Chat ID............" + contact.contact.id);
console.log("Msg ID............." + event.id)
}
);
// Bind 'isWriting' event custom callback
contact.on("isWriting",
function (event) {
console.log("[CTLIVE] On [isWriting] event");
console.log("Started/Stopped writing........", event.bwrite);
}
);
// Bind 'contactEnded' event custom callback
contact.on("contactEnded",
function (event) {
console.log("[CTLIVE] On [contactEnded] event");
}
);
// Bind 'userAdded' event custom callback
// A new participant has benn added in the chat room
contact.on("userAdded",
function (event) {
console.log("[CTLIVE] On [userAdded] event");
}
);
}
);
|
...