'Linkus SDK for Web Core' Usage Example

The simplified sample codes below demonstrate the general workflow for making and receiving calls via 'Linkus SDK for Web Core'.

import { init } from 'ys-webrtc-sdk-core';

    username: '1000',
    secret: 'sdkshajgllliiaggskjhf',
    pbxURL: ''
    .then(operator => {
        // Obtain the 'PhoneOperator' instance, 'PBXOperator' instance, and 'destroy' method.
        const { phone, pbx, destroy } = operator;

        // Create an RTC instance.
        phone.on('newRTCSession', ({callId,session})=>{
            const {status} = session

            // Listen for events in the session.
            session.on('confirmed', {callId,session})=>{
                // A call is successfully connected, the 'session.status.callStatus' changes to 'talking'.
                // Update the user interface, start the call timer.

        // Listen for the 'startSession' events.
            const {status} = session
            if(status.communicationType === 'outbound') {
                // Outbound call.
                // Update the user interface to display 'Calling', indicating that the callee side is ringing.
                // Inbound call.
                // Update the user interface to display 'Connecting'.


        // Listen for Incoming call events.
        phone.on('incoming', (callId,session)=>{
            const {status} = session
            // Pop up an incoming call dialog, displaying the caller's phone number and name. 
            // ...
            // Click the 'Answer' button to trigger the 'answer' method and the 'startSession' event.

        // After listening for events, start registering the SIP UA.

        // ...
        // Click the 'Call' button to call 1001.

    .catch(error => {