SlideShare uma empresa Scribd logo
1 de 76
Baixar para ler offline
Using Groovy to empower WebRTC
Network Systems
Antón R. Yuste
@antonmry
Agenda
●
What is (and isn't WebRTC)
●
Developing your own WebRTC service
●
Groovy & Network Systems
●
TADHack 2015
Once upon a time...
Forever
There was a time...
●
Where we use to see video by using plug-ins and
external software
●
Instant Messaging was delivered using the same
concepts and Voice = Telephony
●
Suddenly everything changed
WebRTC @ Glance
WebRTC offers real time
communication natively
from a web browser
WebRTC @ Glance
WebRTC capable
browser share, including
Mobile, Tablet and
desktop
61%
WebRTC @ Glance
WebRTC is a
“MediaEngine” with
javascript API
API
WebRTC @ Glance
WebRTC is a technology,
NOT a solution,
AND open source
projects too
So, what is WebRTC?
●
A built-in application program interface that enables
browser-to-browser applications for:
●
voice calling
●
video chat
●
peer to peer of any data
●
Media engine in the browser, accessed by JavaScript,
downloaded from web-server.
●
Collaborative W3C and IETF standardization
The WebRTC tree
IMS, LTE
WWW
VoIP
So, what is WebRTC - Technically Speaking?
PEER CONNECTION
(AUDIO, VIDEO, DATA)
WEB SERVER
(WEBRTC CONTROL)
GATEWAY
PEER CONNECTION
(AUDIO, VIDEO, DATA)
PEER CONNECTION
(AUDIO, VIDEO, DATA)
WEB SERVER
(WEBRTC CONTROL)
What isn't WebRTC - Technically Speaking?
●
No MTI coded media
●
No defined signaling mechanism
It's a Standard
Specification and an
opensource project
Signaling – The Two Approach
SIP over WebSockets JSON over WebSockets
Why JSON, XMPP, * and not SIP?
●
Much more easy
●
There are more developers
●
Language of the web
●
And it’s natively supported by browser
●
Drives more SIP into the network
WebRTC Browser Support: Desktop
WebRTC Regional Browser Support: Desktop
A new Sheriff in town
●
August 20, 2014. Microsoft published a blog post
publicly supporting the ORCT draft.
Browser support
WebRTC Browser Support: Mobile
Consideration
●
Lack of WebRTC Support:
●
SDK/library for Windows Phone and IOS devices
●
Hardware support for Mobile Phone
●
Software encoding & decoding will kill your battery
for VP8
●
New device will benefits from power processor
●
Snapdragon 800 4
●
nVidia Tegra 4
Where we are now?
Is WebRTC ready?
… and more!
Major WebRTC Standard APIs
Acquire audio/video
Communicate Media
Communicate Data
MediaStream/getUserMedia
RTCPeerConnection
RTCDataChannel
MediaStream
●
Represents a stream of audio/video (stream from
camera/mike)
●
Multiple Tracks
●
Use navigator.getUserMedia()
MediaStream
var constraints = {video: true};
function successCallback(stream) {
var video =
document.querySelector("video");
video.src =
window.URL.createObjectURL(stream);
}
function errorCallback(error) {
console.log("navigator.getUserMedia error:
", error);
}
navigator.getUserMedia(constraints,
successCallback, errorCallback);
RTCPeerConnection
●
Centre of WebRTC
Standard API.
●
Peer to Peer
Communication
●
Codec, Security,
bandwidth etc.
RTCPeerConnection
pc = new RTCPeerConnection(null);
pc.onaddstream = gotRemoteStream;
pc.addStream(localStream);
pc.createOffer(gotOffer);
function gotOffer(desc) {
pc.setLocalDescription(desc);
sendOffer(desc);
}
function gotAnswer(desc) {
pc.setRemoteDescription(desc);
}
function gotRemoteStream(e) {
attachMediaStream(remoteVideo, e.stream);
}
RTCDataChannel
●
Arbitrary Data
●
File
●
Text
●
Games
●
API Similar to WebSockets
●
Peer to Peer Data
●
Use SCTP
RTCDataChannel
var pc = new webkitRTCPeerConnection(servers,
{optional: [{RtpDataChannels: true}]});
pc.ondatachannel = function(event) {
receiveChannel = event.channel;
receiveChannel.onmessage = function(event){
document.querySelector("div#receive").innerHTML =
event.data;
};
};
sendChannel = pc.createDataChannel("sendDataChannel",
{reliable: false});
document.querySelector("button#send").onclick = function (){
var data = document.querySelector("textarea#send").value;
sendChannel.send(data);
};
WebRTC Signaling
HTML
App
Browser
HTML
App
Browser
Session Description
Protocol
Signaling? Signaling?
Media(RTCP/RTP)
Caller Callee
Session Description
Protocol
WebRTC Offer/Answer Model
HTML
App
Browser
HTML
App
Browser
How ? How ?
Caller Callee
offer answer
ICE/STUN
Caller Callee
media media
STUN
ICE/TURN
Caller Callee
media
STUN STUN
TURN TURN
The entire exchange in a complicated diagram
How to start using WebRTC API ?
Prerequisites
●
Java 7
●
Maven 3.2+
●
Git
●
Your favorite IDE
●
Chrome browser
●
Internet Connection
Practice
git clone https://github.com/antonmry/SpringIOWebRTCSampleApp.git
ant jetty:run
Follow the mantra…
●
Java is Groovy, Groovy is Java.
●
Flat learning curve for Java developers, start with
straight Java syntax then move on to a groovier syntax
as you feel comfortable.
●
Almost 98% Java code is Groovy code, meaning you
can in most changes rename *.java to *.groovy and it
will work.
Template Engine maps messages in both
directions between applications and network
JSON Template
Engine
SIP message
Application Network
Call
Flow
detail
Components and developer extension points
Template Engine configuration
Package
Criteria
Script
template
Script
template
Script
template
Template Library
Criteria
Criteria
The Console Window
Package configuration
Inbound
INVITE
request
criteria
Inbound INVITE Request Template
TemplateContext passed as an argument
Using Script Library method
Creating a future task executed on successful ME response
Script Library
Groovy method specified in Inbound INVITE request template script
Groovy tips and tricks
●
Use “def” to declare variables and make them local:
def b = "foo“.
●
Simplification of a getter method notation: def factory
= context.webFactory // instead of
context.getWebFactory()
●
Safe navigation operator (?.): def errorCode =
context.webMessage?.header?.error_code
●
Check for a null object: if
(context.webMessage?.payload?.sdp)
Groovy tips and tricks
●
Compile static @groovy.transform.CompileStatic (no
dynamic types, compiles better and faster)
●
Iterators
●
’as’ keyword
●
Closures
●
array and list operators * and *. – called ”spread” and
”spread-dot”
●
GPath – similar to xpath but runs on objects not xml
Groovy scripts troubleshooting
●
Add println statements and see output in the system
out, e.g.: println “from=" + from
●
Use log4j and see output in wsc.log file, e.g.
org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(getClass())
logger.info(“groovy info: from=“ + from)
●
When an exception is thrown within a Groovy script, a
stack trace will be logged in the wsc.log file.
Groovy scripts troubleshooting
Groovy scripts troubleshooting
Caused by: groovy.lang.MissingPropertyException: No such property: sipReq for class: Script2
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231
)
at Script2.pkg_register_dir_FROM_APP_typ_request_verb_connect_netsvc_default(Script2.groovy:705)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:952)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
at groovy.lang.Closure.call(Closure.java:411)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.callGlobal(GroovyScriptEngineImpl.java:411)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.callGlobal(GroovyScriptEngineImpl.java:405)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeImpl(GroovyScriptEngineImpl.java:394)
...
Groovy scripts validation
Example SIP Request Variable
// Create REGISTER request
def from = getFromAddress(context)
def to = getToAddress(context)
def sipReq = context.sipFactory.createSipRequest("REGISTER",
from, to)
// Set request URI
sipReq.requestURI =
context.sipFactory.createSipAddress(Constants.PROXY_SIP_URI)
.URI
// Set contact user
if (from.URI?.user) {
sipReq.setContactUser(from.URI.user)
}
// Set sip.instance to allow container to use SIP Outbound
// for routing purposes as defined in RFC 5626
def sipInstance = ""<urn:uuid:" +
java.util.UUID.randomUUID() + ">""
sipReq.setSipContactParameter("+sip.instance", sipInstance)
sipReq.setSipContactParameter("reg-id", "1")
context.subSessionStore.put("sip.instance", sipInstance)
sipReq.send()
GRUUs
A GRUU (Globally Routable User-Agent URI) is a SIP URI which
has a few properties.
?
Example SIP Request Variable
sipReq.setHeader("Supported", "gruu")
// P-Charging-Vector example
def icidValue = context.uniqueId
def myIp =
java.net.InetAddress.localHost.hostAddress
sipReq.setHeader("P-Charging-Vector", "icid-
value=" + icidValue +
";icid-generated-at=" + myIp)
Protecting System Performance
by Removing SIP Messages
if (sipResponse.status < 200) {
// Ignore provisional responses
} else if (sipResponse.status < 300)
// Proceed with processing
}
{...
}
Removing a SIP Header in a
Message
sipReq.removeHeader("headername")
Conditionally Passing SIP Headers
in Messages
def myWebParameter =
context.webMessage?.header.?myParameter
if (myWebParameter) {
sipRequest.setHeader("MyHeader",
myWebParameter)
}
REST
●
Asynchronous and synchronous callback responses
●
Support for HTTP and HTTPS
●
Support for all standard REST methods
●
Support for REST calls during message processing or
WebSocket connection establishment
Defining a REST URL Endpoint Constant
public static final MY_REST_URL =
"http://server:port/rest_endpoint"
Referencing the URL Constant
def restRequest =
context.restClient.createRequest(Constants.MY
_REST_URL...);
Creating a REST Request
def myRestRequest =
context.restClient.createRequest(Constants.MY
_REST_URL, "PUT");
Configuring a REST Request Object
myRestRequest.setAccept(APPLICATION_JSON);
myRestRequest.setAcceptLanguage("en-us", "de-
de", "fr-fr");
myRestRequest.addHeader("My Key", "My
Value");
Sending the REST Request
def xml = { mkp.xmlDeclaration() fish
{ name("salmon") price("10") }};
def myRestFuture = myRestRequest.send(xml,
APPLICATION_XML);
Sending the REST Request
context.getTaskBuilder("processResponse").wit
hArg("myRestFuture", restFuture)
.onSuccess(restFuture).build();
context.getTaskBuilder("processResponse").wit
hArg("myRestFuture", restFuture)
.onError(restFuture).build();
REST Response Handler
void processResponse(TemplateContext context)
{
def result =
context.taskArgs.restFuture.get()
if (result.status == 200) {
def fish = result.value()
if (fish.name.text() == "salmon") {
// Continue processing...
}
} else {
// Handle any errors...
}
}
REST Authentication
def myRestAuthRequest =
context.restClient.createRequest(Constants.MY
_REST_URL, "PUT", true);
def username = "myuserid";
def password = [231, 245, 675, 232, 123] as
byte[];
myRestAuthRequest.setCredentials(username,
password);
tadhack.optaresolutions.com
Add easily
telecom services
to your APPs
Industry-
standard SIP
servlet 2.0,
media control
and Java EE
Example SIP POJO (JSR-359)
@SipServlet
public class FooPOJO {
@Invite
public void incomingCall(SipServletRequest request) {
//...
}
@Bye
public void disconnectCall(SipServletResponse response) {
//...
}
}
WebRTC
Summary
●
WebRTC is a great option to implement or add Real
Time Communication services.
●
Groovy is very good in network systems: it provides
flexibility, easy to use and good performance
●
If you like communications & developing, don't miss
TADHack 2015.
Q & A
Thanks!
@antonmry
www.
serviceandnetworkevolution
.com

Mais conteúdo relacionado

Mais procurados

Advanced MQTT and Kura - EclipseCON 2014
Advanced MQTT and Kura - EclipseCON 2014Advanced MQTT and Kura - EclipseCON 2014
Advanced MQTT and Kura - EclipseCON 2014Eurotech
 
Brushing skills on SignalR for ASP.NET developers
Brushing skills on SignalR for ASP.NET developersBrushing skills on SignalR for ASP.NET developers
Brushing skills on SignalR for ASP.NET developersONE BCG
 
L7 firewall API for Neutron-FWaaS
L7 firewall API for Neutron-FWaaSL7 firewall API for Neutron-FWaaS
L7 firewall API for Neutron-FWaaSnguyen phuong an
 
Building a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istioBuilding a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istioSAMIR BEHARA
 
Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018Alan Quayle
 
Introduction to Istio Service Mesh
Introduction to Istio Service MeshIntroduction to Istio Service Mesh
Introduction to Istio Service MeshGeorgios Andrianakis
 
Hyperledger Fabric EVM Integration Feb 20, 2018
Hyperledger Fabric EVM Integration Feb 20, 2018Hyperledger Fabric EVM Integration Feb 20, 2018
Hyperledger Fabric EVM Integration Feb 20, 2018Arnaud Le Hors
 
Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017Ulf Lilleengen
 
Yotpo microservices
Yotpo microservicesYotpo microservices
Yotpo microservicesRon Barabash
 
Using open source for IoT
Using open source for IoTUsing open source for IoT
Using open source for IoTIan Skerrett
 
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)Victor Pascual Ávila
 
Microservices With Istio Service Mesh
Microservices With Istio Service MeshMicroservices With Istio Service Mesh
Microservices With Istio Service MeshNatanael Fonseca
 
WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...
WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...
WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...Amir Zmora
 

Mais procurados (17)

Advanced MQTT and Kura - EclipseCON 2014
Advanced MQTT and Kura - EclipseCON 2014Advanced MQTT and Kura - EclipseCON 2014
Advanced MQTT and Kura - EclipseCON 2014
 
Brushing skills on SignalR for ASP.NET developers
Brushing skills on SignalR for ASP.NET developersBrushing skills on SignalR for ASP.NET developers
Brushing skills on SignalR for ASP.NET developers
 
WebRTC in action
WebRTC in actionWebRTC in action
WebRTC in action
 
L7 firewall API for Neutron-FWaaS
L7 firewall API for Neutron-FWaaSL7 firewall API for Neutron-FWaaS
L7 firewall API for Neutron-FWaaS
 
VozDigital DevFest 31/10/14
VozDigital DevFest 31/10/14VozDigital DevFest 31/10/14
VozDigital DevFest 31/10/14
 
Building a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istioBuilding a scalable microservice architecture with envoy, kubernetes and istio
Building a scalable microservice architecture with envoy, kubernetes and istio
 
Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018Matrix, The Year To Date, Ben Parsons, TADSummit 2018
Matrix, The Year To Date, Ben Parsons, TADSummit 2018
 
Introduction to Istio Service Mesh
Introduction to Istio Service MeshIntroduction to Istio Service Mesh
Introduction to Istio Service Mesh
 
Hyperledger Fabric EVM Integration Feb 20, 2018
Hyperledger Fabric EVM Integration Feb 20, 2018Hyperledger Fabric EVM Integration Feb 20, 2018
Hyperledger Fabric EVM Integration Feb 20, 2018
 
Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017Messaging-as-a-Service Rivieradev 2017
Messaging-as-a-Service Rivieradev 2017
 
GÉANT TURN pilot
GÉANT TURN pilotGÉANT TURN pilot
GÉANT TURN pilot
 
WebRTC
WebRTCWebRTC
WebRTC
 
Yotpo microservices
Yotpo microservicesYotpo microservices
Yotpo microservices
 
Using open source for IoT
Using open source for IoTUsing open source for IoT
Using open source for IoT
 
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
WebRTC and VoIP: bridging the gap (Kamailio world conference 2013)
 
Microservices With Istio Service Mesh
Microservices With Istio Service MeshMicroservices With Istio Service Mesh
Microservices With Istio Service Mesh
 
WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...
WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...
WebRTC Standards & Implementation Q&A - WebRTC Standards Feature Complete 
No...
 

Semelhante a Using Groovy to empower WebRTC Network Systems

JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK
 
WebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computationWebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computationJooinK
 
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...KAI CHU CHUNG
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13Fred Sauer
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.JooinK
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWTFrancesca Tosi
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitAriya Hidayat
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitAriya Hidayat
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰KAI CHU CHUNG
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitAriya Hidayat
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013Andy Bunce
 
Analyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAriya Hidayat
 
How to Create a Service in Choreo
How to Create a Service in ChoreoHow to Create a Service in Choreo
How to Create a Service in ChoreoWSO2
 
Web Services and Android - OSSPAC 2009
Web Services and Android - OSSPAC 2009Web Services and Android - OSSPAC 2009
Web Services and Android - OSSPAC 2009sullis
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCTim Burks
 
Introduction to WebRTC
Introduction to WebRTCIntroduction to WebRTC
Introduction to WebRTCArt Matsak
 
When third parties stop being polite... and start getting real
When third parties stop being polite... and start getting realWhen third parties stop being polite... and start getting real
When third parties stop being polite... and start getting realCharles Vazac
 
Real-Time Communication Testing Evolution with WebRTC
Real-Time Communication Testing Evolution with WebRTCReal-Time Communication Testing Evolution with WebRTC
Real-Time Communication Testing Evolution with WebRTCAlexandre Gouaillard
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 

Semelhante a Using Groovy to empower WebRTC Network Systems (20)

JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013
 
WebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computationWebRTC ... GWT & in-browser computation
WebRTC ... GWT & in-browser computation
 
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
 
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
apidays LIVE Helsinki - Implementing OpenAPI and GraphQL Services with gRPC b...
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWT
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
 
Analyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile Web
 
How to Create a Service in Choreo
How to Create a Service in ChoreoHow to Create a Service in Choreo
How to Create a Service in Choreo
 
Web Services and Android - OSSPAC 2009
Web Services and Android - OSSPAC 2009Web Services and Android - OSSPAC 2009
Web Services and Android - OSSPAC 2009
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
 
Introduction to WebRTC
Introduction to WebRTCIntroduction to WebRTC
Introduction to WebRTC
 
When third parties stop being polite... and start getting real
When third parties stop being polite... and start getting realWhen third parties stop being polite... and start getting real
When third parties stop being polite... and start getting real
 
Real-Time Communication Testing Evolution with WebRTC
Real-Time Communication Testing Evolution with WebRTCReal-Time Communication Testing Evolution with WebRTC
Real-Time Communication Testing Evolution with WebRTC
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 

Último

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Último (20)

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

Using Groovy to empower WebRTC Network Systems

  • 1. Using Groovy to empower WebRTC Network Systems Antón R. Yuste @antonmry
  • 2. Agenda ● What is (and isn't WebRTC) ● Developing your own WebRTC service ● Groovy & Network Systems ● TADHack 2015
  • 3. Once upon a time...
  • 5. There was a time... ● Where we use to see video by using plug-ins and external software ● Instant Messaging was delivered using the same concepts and Voice = Telephony ● Suddenly everything changed
  • 6. WebRTC @ Glance WebRTC offers real time communication natively from a web browser
  • 7. WebRTC @ Glance WebRTC capable browser share, including Mobile, Tablet and desktop 61%
  • 8. WebRTC @ Glance WebRTC is a “MediaEngine” with javascript API API
  • 9. WebRTC @ Glance WebRTC is a technology, NOT a solution, AND open source projects too
  • 10. So, what is WebRTC? ● A built-in application program interface that enables browser-to-browser applications for: ● voice calling ● video chat ● peer to peer of any data ● Media engine in the browser, accessed by JavaScript, downloaded from web-server. ● Collaborative W3C and IETF standardization
  • 11. The WebRTC tree IMS, LTE WWW VoIP
  • 12. So, what is WebRTC - Technically Speaking? PEER CONNECTION (AUDIO, VIDEO, DATA) WEB SERVER (WEBRTC CONTROL) GATEWAY PEER CONNECTION (AUDIO, VIDEO, DATA) PEER CONNECTION (AUDIO, VIDEO, DATA) WEB SERVER (WEBRTC CONTROL)
  • 13. What isn't WebRTC - Technically Speaking? ● No MTI coded media ● No defined signaling mechanism It's a Standard Specification and an opensource project
  • 14. Signaling – The Two Approach SIP over WebSockets JSON over WebSockets
  • 15. Why JSON, XMPP, * and not SIP? ● Much more easy ● There are more developers ● Language of the web ● And it’s natively supported by browser ● Drives more SIP into the network
  • 17. WebRTC Regional Browser Support: Desktop
  • 18. A new Sheriff in town ● August 20, 2014. Microsoft published a blog post publicly supporting the ORCT draft.
  • 21. Consideration ● Lack of WebRTC Support: ● SDK/library for Windows Phone and IOS devices ● Hardware support for Mobile Phone ● Software encoding & decoding will kill your battery for VP8 ● New device will benefits from power processor ● Snapdragon 800 4 ● nVidia Tegra 4
  • 22. Where we are now?
  • 23. Is WebRTC ready? … and more!
  • 24. Major WebRTC Standard APIs Acquire audio/video Communicate Media Communicate Data MediaStream/getUserMedia RTCPeerConnection RTCDataChannel
  • 25. MediaStream ● Represents a stream of audio/video (stream from camera/mike) ● Multiple Tracks ● Use navigator.getUserMedia()
  • 26. MediaStream var constraints = {video: true}; function successCallback(stream) { var video = document.querySelector("video"); video.src = window.URL.createObjectURL(stream); } function errorCallback(error) { console.log("navigator.getUserMedia error: ", error); } navigator.getUserMedia(constraints, successCallback, errorCallback);
  • 27. RTCPeerConnection ● Centre of WebRTC Standard API. ● Peer to Peer Communication ● Codec, Security, bandwidth etc.
  • 28. RTCPeerConnection pc = new RTCPeerConnection(null); pc.onaddstream = gotRemoteStream; pc.addStream(localStream); pc.createOffer(gotOffer); function gotOffer(desc) { pc.setLocalDescription(desc); sendOffer(desc); } function gotAnswer(desc) { pc.setRemoteDescription(desc); } function gotRemoteStream(e) { attachMediaStream(remoteVideo, e.stream); }
  • 29. RTCDataChannel ● Arbitrary Data ● File ● Text ● Games ● API Similar to WebSockets ● Peer to Peer Data ● Use SCTP
  • 30. RTCDataChannel var pc = new webkitRTCPeerConnection(servers, {optional: [{RtpDataChannels: true}]}); pc.ondatachannel = function(event) { receiveChannel = event.channel; receiveChannel.onmessage = function(event){ document.querySelector("div#receive").innerHTML = event.data; }; }; sendChannel = pc.createDataChannel("sendDataChannel", {reliable: false}); document.querySelector("button#send").onclick = function (){ var data = document.querySelector("textarea#send").value; sendChannel.send(data); };
  • 31. WebRTC Signaling HTML App Browser HTML App Browser Session Description Protocol Signaling? Signaling? Media(RTCP/RTP) Caller Callee Session Description Protocol
  • 35. The entire exchange in a complicated diagram
  • 36. How to start using WebRTC API ?
  • 37. Prerequisites ● Java 7 ● Maven 3.2+ ● Git ● Your favorite IDE ● Chrome browser ● Internet Connection
  • 39. Follow the mantra… ● Java is Groovy, Groovy is Java. ● Flat learning curve for Java developers, start with straight Java syntax then move on to a groovier syntax as you feel comfortable. ● Almost 98% Java code is Groovy code, meaning you can in most changes rename *.java to *.groovy and it will work.
  • 40. Template Engine maps messages in both directions between applications and network JSON Template Engine SIP message Application Network
  • 42. Components and developer extension points
  • 46. Inbound INVITE Request Template TemplateContext passed as an argument Using Script Library method Creating a future task executed on successful ME response
  • 47. Script Library Groovy method specified in Inbound INVITE request template script
  • 48. Groovy tips and tricks ● Use “def” to declare variables and make them local: def b = "foo“. ● Simplification of a getter method notation: def factory = context.webFactory // instead of context.getWebFactory() ● Safe navigation operator (?.): def errorCode = context.webMessage?.header?.error_code ● Check for a null object: if (context.webMessage?.payload?.sdp)
  • 49. Groovy tips and tricks ● Compile static @groovy.transform.CompileStatic (no dynamic types, compiles better and faster) ● Iterators ● ’as’ keyword ● Closures ● array and list operators * and *. – called ”spread” and ”spread-dot” ● GPath – similar to xpath but runs on objects not xml
  • 50. Groovy scripts troubleshooting ● Add println statements and see output in the system out, e.g.: println “from=" + from ● Use log4j and see output in wsc.log file, e.g. org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(getClass()) logger.info(“groovy info: from=“ + from) ● When an exception is thrown within a Groovy script, a stack trace will be logged in the wsc.log file.
  • 52. Groovy scripts troubleshooting Caused by: groovy.lang.MissingPropertyException: No such property: sipReq for class: Script2 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231 ) at Script2.pkg_register_dir_FROM_APP_typ_request_verb_connect_netsvc_default(Script2.groovy:705) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1085) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:952) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909) at groovy.lang.Closure.call(Closure.java:411) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.callGlobal(GroovyScriptEngineImpl.java:411) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.callGlobal(GroovyScriptEngineImpl.java:405) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.invokeImpl(GroovyScriptEngineImpl.java:394) ...
  • 54. Example SIP Request Variable // Create REGISTER request def from = getFromAddress(context) def to = getToAddress(context) def sipReq = context.sipFactory.createSipRequest("REGISTER", from, to) // Set request URI sipReq.requestURI = context.sipFactory.createSipAddress(Constants.PROXY_SIP_URI) .URI // Set contact user if (from.URI?.user) { sipReq.setContactUser(from.URI.user) } // Set sip.instance to allow container to use SIP Outbound // for routing purposes as defined in RFC 5626 def sipInstance = ""<urn:uuid:" + java.util.UUID.randomUUID() + ">"" sipReq.setSipContactParameter("+sip.instance", sipInstance) sipReq.setSipContactParameter("reg-id", "1") context.subSessionStore.put("sip.instance", sipInstance) sipReq.send()
  • 55. GRUUs A GRUU (Globally Routable User-Agent URI) is a SIP URI which has a few properties. ?
  • 56. Example SIP Request Variable sipReq.setHeader("Supported", "gruu") // P-Charging-Vector example def icidValue = context.uniqueId def myIp = java.net.InetAddress.localHost.hostAddress sipReq.setHeader("P-Charging-Vector", "icid- value=" + icidValue + ";icid-generated-at=" + myIp)
  • 57. Protecting System Performance by Removing SIP Messages if (sipResponse.status < 200) { // Ignore provisional responses } else if (sipResponse.status < 300) // Proceed with processing } {... }
  • 58. Removing a SIP Header in a Message sipReq.removeHeader("headername")
  • 59. Conditionally Passing SIP Headers in Messages def myWebParameter = context.webMessage?.header.?myParameter if (myWebParameter) { sipRequest.setHeader("MyHeader", myWebParameter) }
  • 60. REST ● Asynchronous and synchronous callback responses ● Support for HTTP and HTTPS ● Support for all standard REST methods ● Support for REST calls during message processing or WebSocket connection establishment
  • 61. Defining a REST URL Endpoint Constant public static final MY_REST_URL = "http://server:port/rest_endpoint" Referencing the URL Constant def restRequest = context.restClient.createRequest(Constants.MY _REST_URL...);
  • 62. Creating a REST Request def myRestRequest = context.restClient.createRequest(Constants.MY _REST_URL, "PUT");
  • 63. Configuring a REST Request Object myRestRequest.setAccept(APPLICATION_JSON); myRestRequest.setAcceptLanguage("en-us", "de- de", "fr-fr"); myRestRequest.addHeader("My Key", "My Value");
  • 64. Sending the REST Request def xml = { mkp.xmlDeclaration() fish { name("salmon") price("10") }}; def myRestFuture = myRestRequest.send(xml, APPLICATION_XML);
  • 65. Sending the REST Request context.getTaskBuilder("processResponse").wit hArg("myRestFuture", restFuture) .onSuccess(restFuture).build(); context.getTaskBuilder("processResponse").wit hArg("myRestFuture", restFuture) .onError(restFuture).build();
  • 66. REST Response Handler void processResponse(TemplateContext context) { def result = context.taskArgs.restFuture.get() if (result.status == 200) { def fish = result.value() if (fish.name.text() == "salmon") { // Continue processing... } } else { // Handle any errors... } }
  • 67. REST Authentication def myRestAuthRequest = context.restClient.createRequest(Constants.MY _REST_URL, "PUT", true); def username = "myuserid"; def password = [231, 245, 675, 232, 123] as byte[]; myRestAuthRequest.setCredentials(username, password);
  • 68.
  • 72. Example SIP POJO (JSR-359) @SipServlet public class FooPOJO { @Invite public void incomingCall(SipServletRequest request) { //... } @Bye public void disconnectCall(SipServletResponse response) { //... } }
  • 74. Summary ● WebRTC is a great option to implement or add Real Time Communication services. ● Groovy is very good in network systems: it provides flexibility, easy to use and good performance ● If you like communications & developing, don't miss TADHack 2015.
  • 75. Q & A