45
Write a FreeSWITCH GUI with React and Lua Seven Du Yantai Xiaoyingtao Network Technology ClueCon 2017

Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

  • Upload
    others

  • View
    99

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Write a FreeSWITCH GUI with React and Lua

Seven Du

Yantai Xiaoyingtao Network Technology

ClueCon 2017

Page 2: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser
Page 3: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Yantai China

Page 4: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Yantai China

Page 5: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser
Page 6: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Met FreeSWITCH at 2007Start patching FreeSWITCH from 2008FreeSWITCH coding all the time

Page 7: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser
Page 8: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser
Page 9: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

http://book.dujinfang.com

Page 10: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

GUI for FreeSWITCH

Page 11: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

FusionPBX 2600Hz …

Page 12: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

FreeSWITCH Portal

ember.jsmod_xml_rpc

Page 13: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

React.jsmod_verto

Page 14: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Natively built in FreeSWITCH, No Apache/Nginx/PHP …C, Lua, SQLite, PostgreSQLRestful APIReact.jsPBX, Small callcenters,…Audio & Video ConferencesIVR BlocksScales from single box to the clouldOpen source https://github.com/seven1240/xui

Features

Page 15: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

X86

ARM

Raspberry PI

Orange PI

CubieTruck

Mac

Windows

Linux

Page 16: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser
Page 17: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

XSWITCH

= +FreeSWITCH

https://xswitch.cn

Page 18: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser
Page 19: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Bypass media

Page 20: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

http in mod_verto

Page 21: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

<vhosts> <vhost domain="localhost"> <param name="alias" value="seven.local freeswitch.org"/> <param name="root" value="$${base_dir}/xui/www"/> <param name="script-root" value="$${base_dir}/xui/lua/xui/vendor"/> <param name="index" value="index.html"/> <rewrites> <rule expression="^/api" value="/__xtra_init__.lua"/> </rewrites> </vhost> </vhosts>

Page 22: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

xTra

Page 23: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

MVC

SinatraExpressFlaskBottleMercury

Page 24: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

delete("/:uuid", function(params) api("uuid_kill " .. params.uuid) return "ok" end)

-- psudo code channels operation RESTful API

get("/", function(params) return api("show channels as json") end)

get("/:uuid", function(params) return api("uuid_dump " .. params.uuid .. " json") end)

post("/", function(params) return api("originate user/" .. params.dest_number .. " ... ") end)

put("/:uuid", function(prams) return api("uuid_media on/off ...") end)

Page 25: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

xdb — simple ORM

Page 26: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

delete("/:id", function(params) xdb.delete(“users”, params.id) return params.id end)

-- psudo code users RESTful API

get("/", function(params) return xdb.find_all(“users”) end)

get("/:id", function(params) return xdb.find(“users”, params.id) end)

post("/", function(params) return xdb.create(“users”, params) end)

put("/:id", function(params) user = params.request user.id = params.id return xdb.update(“users”, user) end)

SELECT * FROM users

SELECT * FROM users WHERE id = params.id

INSERT INTO users (name, password) VALUES …

UPDATE users SET name = name, extension = … WHERE id = params.id

DELETE users WHERE id = params.id

Page 27: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Binding to FreeSWITCH

Page 28: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Lua bindings

<param name=“xml-handler-script" value=“/usr/local/freeswitch/xui/lua/xui/fs_xml_handler.lua"/>

<param name=“xml-handler-bindings"value="dialplan|result|config|directory|channels|chatplan|languages"/>

Page 29: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

React

https://facebook.github.io/react/

Page 30: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Verto ES6

https://freeswitch.org/jira/browse/FS-10028

Page 31: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

react-bootstrapreact-routeri18n-reactFetch instead of XHR

Page 32: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

No redux

Page 33: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

window.addEventListener("verto-login", this.handleVertoLogin); window.addEventListener("verto-disconnect", this.handleVertoDisconnect);

fire_event("verto-login", v);

Page 34: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Demo

Page 35: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Early stage and in active developmentUsed as office PBXTiny callcentersCall routing with blocksVideo conferences…

Status

Page 36: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser
Page 37: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

416

Page 38: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

FreeSWITCH 0 FreeSWITCH 1

FreeSWITCH 2

FreeSWITCH 3

FreeSWITCH 4

FreeSWITCH 5Media

SIPBypass Media

RTP Media

RTP Media between servers

SIP

Connecting two conferences

Page 39: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

FreeSWITCH 0

FS1

FS2

FS3

FS4

FS5

FS1

FS2

FS3

FS4

FS5

originate sofia/external/3000@FS1 3000

originate sofia/external/3000@FS2 3000

originate sofia/external/3000@FS3 3000

originate sofia/external/3000@FS4 3000

originate sofia/external/3000@FS5 3000

How ?

Page 40: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

400+ video memers on 7 servers with 30% CPU each

720p

passthrough

Page 41: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

FS1 FS2 FS3 FS4 FS5FS1

for (var i = 0; i < nodes; i++) verto_connectors[i] = new Verto();

Page 42: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache

mod_verto and Lua in the back, react.js in browser

SQLite/PostgreSQL

Lua bindings, mod_xml_curl designed for the future maybe for clustering

mod_cdr_sqlite or mod_odbc_cdr for CDR

mod_curl for HTTP client talking to other API providers

IVR blocks

Audio/Video calls/conferences with mod_verto

Web terminal

Page 43: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

Security?

Page 44: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

We are hiring

Page 45: Write a FreeSWITCH GUI with React and Lua - GitHub...Native UI builtin FreeSWITCH, no 3rd party deps, optionally behind Nginx/Apache mod_verto and Lua in the back, react.js in browser

https://github.com/seven1240/xui

@dujinfang

[email protected]