Mountain View
Jabber SDK API Documentation

Tutorial: Handle Conversation Events

Handle Conversation Events

Title Telephony conversation events are global events. They are not specific to individual TelephonyConversation. Because of that reason list of TelephonyConversation objects needs to be managed manually. In order to receive TelephonyConversation objects following event handlers must be set:

        // Called when we have a new incoming conversation.
        function onConversationIncoming(conversation)
        {
            // Handle event...
        }

        // Called when we have started a new coversation.
        function onConversationOutgoing(conversation)
        {
        // Handle event...
        }

        // Called when conversation has started. This happens when incoming/outgoing conversation has been answered.
        function onConversationStarted(conversation)
        {
            // Handle event...
        }

        // Called when conversation's capabilities and/or state has changed.
        function onConversationUpdated(conversation)
        {
            // Handle event;
        }

        // Called when conversation has ended.
        function onConversationEnded(conversation)
        {
            // Handle event...
        }

        cwic.TelephonyController.addEventHandler("onConversationIncoming", onConversationIncoming);
        cwic.TelephonyController.addEventHandler("onConversationOutgoing" onConversationOutgoing);
        cwic.TelephonyController.addEventHandler("onConversationStarted" onConversationStarted);
        cwic.TelephonyController.addEventHandler("onConversationUpdated", onConversationUpdated);
        cwic.TelephonyController.addEventHandler("onConversationEnded", onConversationEnded);
    

Manage Telephony Conversation List

In the snippet below it will be demonstrated one of the ways how manage telephony conversation list (event handlers from previous snippet will be updated for this example):

        // Since conversation objects are received through various events, we need to manage them.
        // Best practice is to add conversation to the list if it is not already present, but if
        // it is we should replace him with "updated" one. Each conversation has unique id, which can
        // be used to manage them easily.
        var telephonyConversations;

        function onConversationIncoming(conversation)
        {
            // Since we are receiving a new conversation object we should add it to a list.
            conversationList[conversation.id] = conversation;

            // Handle event...
        }

        function onConversationOutgoing(conversation)
        {
            // Since we are receiving a new conversation object we should add it to a list.
            conversationList[conversation.id] = conversation;

            // Handle event...
        }

        function onConversationStarted(conversation)
        {
            // Since we have this conversation in our list we should replace it.
            conversationList[conversation.id] = conversation;

            // Handle event...
        }

        function onConversationUpdated(conversation)
        {
            // Since we have this conversation in our list we should replace it.
            conversationList[conversation.id] = conversation;

            // Handle event;
        }

        function onConversationEnded(conversation)
        {
            // Since conversation has ended we should delete it from the list.
            delete conversationList[conversation.id];

            // Handle event...
        }
    

Next

Previous