Giter VIP home page Giter VIP logo

Comments (1)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 30, 2024
While there is no simple built in solution to directly use MWI right now, you 
can easily just implement your own MWI subscription using the subscribe 
function. Tested this method with Asterisk and it works just fine. If someone 
feels like it they can just create wrapper functions in the sipml5 source code 
to use the below logic, but I'm sure testing is needed for use with other PBX 
platforms. The stuff in sip_caps is probably not needed.

function SubscribeMWI() {
    console.log("Softphone: Subscribing to MWI");
    var softphoneMWISession = softphoneSIPStack.newSession('subscribe', {
        expires: 300,
        events_listener: {
            events: '*', listener:
            function (e) {
                if (e.type == 'i_notify' && e.getContentType() == 'application/simple-message-summary') {
                    var matches = e.getContentString().match(/Voice\-Message: ([0-9]+)\/([0-9]+)/);
                    if (matches.length == 3) {
                        var newMessages = matches[1],
                            oldMessages = matches[2];
                        //TODO: Use newMessages and oldMessages however you please, you probably only care about newMessages
                    }
                } else if (e.type == 'connected') {
                    console.log('Softphone: Subscription to MWI successful');
                } else if (e.type == 'terminated') {
                    console.log('Softphone: Subscription to MWI failed');
                    //TODO: Attempt to subscribe again in a couple minutes? Or bail out.
                }
            }
        },
        sip_headers: [
            { name: 'Event', value: 'message-summary' },
            { name: 'Accept', value: 'application/simple-message-summary' }
        ],
        sip_caps: [
            { name: '+g.oma.sip-im', value: null },
            { name: '+audio', value: null },
            { name: 'language', value: '\"en\"' }
        ]
    });
    softphoneMWISession.subscribe('PUT_THE_CURRENT_USERS_AUTH_ID_OR_EXTENSION_HERE');
}

Original comment by [email protected] on 8 Jan 2015 at 5:27

from sipml5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.