Search Results for

    Show / Hide Table of Contents

    Make an Outbound SIP Call

    You can connect WebRTC and SIP clients seamlessly in a single conference. LiveSwitch SIP Connector allows your app to make audio calls to SIP endpoints.

    Note

    LiveSwitch doesn't support making video calls with the SIP Connector.

    Before making an outbound call, make sure that you have installed and configured the SIP Connector.

    Note

    About the code examples on this page:

    • For Unity, use the C# code.
    • For macOS, use the iOS code.

    Make a Call

    To make an outbound call, obtain a reference to the channel that you want to add the SIP user to. Invoke the Channel instance's Invite method and specify both the user ID of the SIP endpoint and the protocol. The protocol parameter must be either tel or sip.

    The Invite method returns a promise, which resolves if the invitation is sent successfully, and is rejected if it is not sent. Note that the resolve action does not mean that the remote SIP user has connected to the conference. It only means that the SIP Connector has successfully received the invitation and forwarded it to the remote SIP user. If the remote party accepts the invitation, they are added to the conference.

    An example is shown below:

    • CSharp
    • Android
    • iOS
    • JavaScript
    • macOS
    • .NET MAUI
    FM.LiveSwitch.Channel channel;
    
    channel.Invite("1234", "tel").Then((FM.LiveSwitch.Invitation invitation) =>
    {
        Console.WriteLine("sent SIP invitation");
    }).Fail(ex =>
    {
        Console.WriteLine("failed to send SIP invitation");
    });
    
    fm.liveswitch.Channel channel;
    
    channel.invite("1234", "tel").then((fM.liveswitch.invitation invitation) -> {
        System.out.println("sent SIP invitation");
    }).Fail(ex => {
        System.out.println("failed to send SIP invitation");
    });
    
    FMLiveSwitchChannel channel
    
    channel.invite("1234", "tel").then(resolveBlock: { (invitation:FMLiveSwitchInvitation) in
        print("sent SIP invitation")
    }).fail(rejectBlock: { (ex:NSException) in
        print("failed to send SIP invitation")
    })
    
    var channel;
    
    channel.invite("1234", "tel").then(function(invitation) {
        console.log("sent SIP invitation");
    }.fail(function(ex) {
        console.log("failed to send SIP invitation");
    });
    
    FMLiveSwitchChannel channel
    
    channel.invite("1234", "tel").then(resolveBlock: { (invitation:FMLiveSwitchInvitation) in
        print("sent SIP invitation")
    }).fail(rejectBlock: { (ex:NSException) in
        print("failed to send SIP invitation")
    })
    
    FM.LiveSwitch.Channel channel;
    
    channel.Invite("1234", "tel").Then((FM.LiveSwitch.Invitation invitation) =>
    {
        Console.WriteLine("sent SIP invitation");
    }).Fail(ex =>
    {
        Console.WriteLine("failed to send SIP invitation");
    });
    

    Cancel a Call

    The Invite method's promise object returns an FM.LiveSwitch.Invitation instance when successful. You can use this object to cancel the invitation. To cancel a call, invoke the Cancel method of the Invitation instance. Note that once an outgoing call is answered, you can no longer cancel the invitation.

    An example is shown below:

    • CSharp
    • Android
    • iOS
    • JavaScript
    • macOS
    • .NET MAUI
    FM.LiveSwitch.Channel channel;
    
    channel.Invite("1234", "tel").Then((FM.LiveSwitch.Invitation invitation) =>
    {
        Console.WriteLine("sent SIP invitation");
    
        invitation.Cancel().Then(obj =>
        {
            Console.WriteLine("cancelled SIP invitation");
        }).Fail(ex =>
        {
            Console.WriteLine("failed to cancel SIP invitation");
        });
    }).Fail(ex =>
    {
        Console.WriteLine("failed to send SIP invitation");
    });
    
    fm.liveswitch.Channel channel;
    
    channel.invite("1234", "tel").then((fm.liveswitch.Invitation invitation) -> {
        System.out.println("sent SIP invitation");
    
        invitation.cancel().then(obj -> {
            System.out.println("cancelled SIP invitation");
        }).fail(ex -> {
            System.out.println("failed to cancel SIP invitation");
        });
    }).Fail(ex -> {
        System.out.println("failed to send SIP invitation");
    });
    
    FMLiveSwitchChannel channel
    
    channel.invite(userId:"1234", protocol:"tel").then(resolveBlock: { (invitation:FMLiveSwitchInvitation) in
        print("sent SIP invitation")
    
        invitation.cancel().then(resolveBlock: { (obj) in
            print("cancelled SIP invitation")
        }).fail(rejectBlock: { (ex) in
            print("failed to cancel SIP invitation")
        })
    }).fail(rejectBlock: { (ex) in
        print("failed to send SIP invitation")
    })
    
    var channel;
    
    channel.invite("1234", "tel").then(function(invitation) {
        console.log("sent SIP invitation");
    
        invitation.cancel().then(function(obj) {
            console.log("cancelled SIP invitation");
        }).fail(function(ex) {
            console.log("failed to cancel SIP invitation");
        });
    }.fail(function(ex) {
        console.log("failed to send SIP invitation");
    });
    
    FMLiveSwitchChannel channel
    
    channel.invite(userId:"1234", protocol:"tel").then(resolveBlock: { (invitation:FMLiveSwitchInvitation) in
        print("sent SIP invitation")
    
        invitation.cancel().then(resolveBlock: { (obj) in
            print("cancelled SIP invitation")
        }).fail(rejectBlock: { (ex) in
            print("failed to cancel SIP invitation")
        })
    }).fail(rejectBlock: { (ex) in
        print("failed to send SIP invitation")
    })
    
    FM.LiveSwitch.Channel channel;
    
    channel.Invite("1234", "tel").Then((FM.LiveSwitch.Invitation invitation) =>
    {
        Console.WriteLine("sent SIP invitation");
    
        invitation.Cancel().Then(obj =>
        {
            Console.WriteLine("cancelled SIP invitation");
        }).Fail(ex =>
        {
            Console.WriteLine("failed to cancel SIP invitation");
        });
    }).Fail(ex =>
    {
        Console.WriteLine("failed to send SIP invitation");
    });
    
    In This Article
    Back to top Copyright © LiveSwitch Inc. All Rights Reserved.Documentation for LiveSwitch Version 1.24.6