Coder Social home page Coder Social logo

modfreeswitch's Introduction

.NET FreeSwitch Library

Build status

Overview

This library helps interact with the FreeSwitch via its mod_event_socket. For more information about the mod_event_socket refer to FreeSwitch web site. The framework is written using DotNetty. In its current state it can help build IVR applications more quickly.

Features

The library in its current state can be used to interact with FreeSwitch easily in:

  • Inbound mode Event Socket Inbound
  • Outbound mode Event Socket Outbound
  • One good thing it has is that you can implement your own FreeSwitch message encoder and decoder if you do not want to use the built-in ones

License

Apache License 2.0

Installation

For the meantime there is no Nuget package available for it. Just clone it and build it and you are ready to go.

Example

    internal class Program {
        private static readonly Logger _logger = LogManager.GetCurrentClassLogger();

        private static void Main(string[] args) {
            const string address = "192.168.74.128";
            const string password = "ClueCon";
            const int port = 8021;
            const int ServerPort = 10000;

            var client = new OutboundSession(address, port, password);
            client.ConnectAsync()
                .ConfigureAwait(false);

            Thread.Sleep(1000);

            _logger.Info("Connected and Authenticated {0}", client.CanSend());
            var @event = "plain CHANNEL_HANGUP CHANNEL_HANGP_COMPLETE";
            var subscribed = client.SubscribeAsync(@event)
                .ConfigureAwait(false);

 
            var commandString = "sofia profile external gwlist up";
            var response = client.SendApiAsync(new ApiCommand(commandString))
                .ConfigureAwait(false);
            _logger.Warn("Api Response {0}", response.GetAwaiter().GetResult().ReplyText);


            var inboundServer = new InboundServer(ServerPort, new DefaultInboundSession());
            inboundServer.StartAsync().Wait(500);
            string callCommand = "{ignore_early_media=false,originate_timeout=120}sofia/gateway/smsghlocalsip/233289063817 &socket(192.168.74.1:10000 async full)";

            client.SendBgApiAsync(new BgApiCommand("originate", callCommand)).Wait(500);

            System.Console.ReadKey();
        }
    }

    public class DefaultInboundSession : InboundSession {
        private const string AudioFile = "https://s3.amazonaws.com/plivocloud/Trumpet.mp3";
        private readonly Logger _logger = LogManager.GetCurrentClassLogger();

        public override Task HandleEvents(EslEvent @event,
            EslEventType eventType) {
            _logger.Debug(@event);
            return Task.CompletedTask;
        }

        public override Task PreHandleAsync() {
            return Task.CompletedTask;
        }

        public override async Task HandleAsync() {
            await PlayAsync(AudioFile);
        }
    }

modfreeswitch's People

Contributors

tochemey avatar

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.