SlideShare a Scribd company logo
SockJS Intro




               Ngoc Dao
Do you know WebSocket?
WebSocket
<script>
var sock = new WebSocket('ws://domain/my_prefix');

sock.onopen = function() {
  console.log('open');
};

sock.onmessage = function(e) {
  console.log('message', e.data);
};

sock.onclose = function() {
  console.log('close');               Server can push data
};                                  to browsers when it wants
</script>
WebSocket
    New browsers are required:
●   Internet Explorer: 10
●   Firefox: 6
●   Chrome: 4
●   Safari: 5
●   Opera: 12.10
SockJS
●   Provides WebSocket-like API
●   Supports all browsers, e.g. IE 6
●   Transports: websocket xhr-streaming xdr-
    streaming iframe-eventsource iframe-htmlfile
    xhr-polling xdr-polling iframe-xhr-polling jsonp-
    polling
●   Requires
     Client side: sockjs.js
     Server side: SockJS server side library
WebSocket vs SockJS
WebSocket                                        SockJS
<script>                                         <script>
var sock = new WebSocket('ws://domain/my_ws');   var sock = new SockJS('http://domain/my_prefix');
sock.onopen = function() {                       sock.onopen = function() {
 console.log('open');                             console.log('open');
};                                               };
sock.onmessage = function(e) {                   sock.onmessage = function(e) {
 console.log('message', e.data);                  console.log('message', e.data);
};                                               };
sock.onclose = function() {                      sock.onclose = function() {
 console.log('close');                            console.log('close');
};                                               };
</script>                                        </script>
Links
●   Client side:
    <script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
    https://github.com/sockjs/sockjs-client
●   Server side:
    Node.js: https://github.com/sockjs/sockjs-node
    Ruby: https://github.com/sockjs/sockjs-ruby
    Python: https://github.com/MrJoes/sockjs-tornado
    JVM:
     https://github.com/vert-x/vert.x
     https://github.com/ngocdaothanh/xitrum
    etc.
Links
●   Client side:
    <script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script>
    https://github.com/sockjs/sockjs-client
●   Server side:
    Node.js: https://github.com/sockjs/sockjs-node
    Ruby: https://github.com/sockjs/sockjs-ruby
    Python: https://github.com/MrJoes/sockjs-tornado
    JVM:
     https://github.com/vert-x/vert.x
     https://github.com/ngocdaothanh/xitrum
    etc.
Demo
https://github.com/sockjs/sockjs-node/tree/master/examples/echo
git clone git://github.com/sockjs/sockjs-node.git
cd sockjs-node/examples/echo
npm install
node server.js
SockJS protocol
If you want to implement a server side for SockJS,
or just want to know how SockJS works:
https://github.com/sockjs/sockjs-protocol
http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html
SockJS vs Socket.IO
●   Socket.IO ≈ SockJS + α
●   SockJS is way simpler, closer to WebSocket
    => SockJS has lots of server side
    implementations for many languages
Ad

More Related Content

What's hot (20)

Physical Penetration Testing (RootedCON 2015)
Physical Penetration Testing (RootedCON 2015)Physical Penetration Testing (RootedCON 2015)
Physical Penetration Testing (RootedCON 2015)
Eduardo Arriols Nuñez
 
Bai 10
Bai 10Bai 10
Bai 10
Hồng Hải Đàm Quang
 
NTFS Forensics
NTFS Forensics NTFS Forensics
NTFS Forensics
nullowaspmumbai
 
Android malware presentation
Android malware presentationAndroid malware presentation
Android malware presentation
Sandeep Joshi
 
1. Security and Risk Management
1. Security and Risk Management1. Security and Risk Management
1. Security and Risk Management
Sam Bowne
 
Threat Hunting Techniques.pdf
Threat Hunting Techniques.pdfThreat Hunting Techniques.pdf
Threat Hunting Techniques.pdf
infosecTrain
 
Endpoint Security
Endpoint SecurityEndpoint Security
Endpoint Security
Ahmed Hashem El Fiky
 
3170725_Unit-1.pptx
3170725_Unit-1.pptx3170725_Unit-1.pptx
3170725_Unit-1.pptx
YashPatel132112
 
Computer Worms
Computer WormsComputer Worms
Computer Worms
sadique_ghitm
 
Addressing the cyber kill chain
Addressing the cyber kill chainAddressing the cyber kill chain
Addressing the cyber kill chain
Symantec Brasil
 
Ntfs forensics
Ntfs forensicsNtfs forensics
Ntfs forensics
n|u - The Open Security Community
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Windows firewall
Windows firewallWindows firewall
Windows firewall
VC Infotech
 
MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...
MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...
MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...
MITRE - ATT&CKcon
 
Cyber kill chain
Cyber kill chainCyber kill chain
Cyber kill chain
Ankita Ganguly
 
Securing password
Securing passwordSecuring password
Securing password
splendorcollege
 
Advanced Persistent Threat
Advanced Persistent ThreatAdvanced Persistent Threat
Advanced Persistent Threat
Ammar WK
 
SANS Windows Artifact Analysis 2012
SANS Windows Artifact Analysis 2012SANS Windows Artifact Analysis 2012
SANS Windows Artifact Analysis 2012
Rian Yulian
 
What is Penetration & Penetration test ?
What is Penetration & Penetration test ?What is Penetration & Penetration test ?
What is Penetration & Penetration test ?
Bhavin Shah
 
Physical Penetration Testing (RootedCON 2015)
Physical Penetration Testing (RootedCON 2015)Physical Penetration Testing (RootedCON 2015)
Physical Penetration Testing (RootedCON 2015)
Eduardo Arriols Nuñez
 
Android malware presentation
Android malware presentationAndroid malware presentation
Android malware presentation
Sandeep Joshi
 
1. Security and Risk Management
1. Security and Risk Management1. Security and Risk Management
1. Security and Risk Management
Sam Bowne
 
Threat Hunting Techniques.pdf
Threat Hunting Techniques.pdfThreat Hunting Techniques.pdf
Threat Hunting Techniques.pdf
infosecTrain
 
Addressing the cyber kill chain
Addressing the cyber kill chainAddressing the cyber kill chain
Addressing the cyber kill chain
Symantec Brasil
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria
 
Windows firewall
Windows firewallWindows firewall
Windows firewall
VC Infotech
 
MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...
MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...
MITRE ATT&CKcon 2018: Helping Your Non-Security Executives Understand ATT&CK ...
MITRE - ATT&CKcon
 
Advanced Persistent Threat
Advanced Persistent ThreatAdvanced Persistent Threat
Advanced Persistent Threat
Ammar WK
 
SANS Windows Artifact Analysis 2012
SANS Windows Artifact Analysis 2012SANS Windows Artifact Analysis 2012
SANS Windows Artifact Analysis 2012
Rian Yulian
 
What is Penetration & Penetration test ?
What is Penetration & Penetration test ?What is Penetration & Penetration test ?
What is Penetration & Penetration test ?
Bhavin Shah
 

Viewers also liked (20)

Using SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JSUsing SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JS
Kazuhiro Kotsutsumi
 
Websockets and SockJS, Real time chatting
Websockets and SockJS, Real time chattingWebsockets and SockJS, Real time chatting
Websockets and SockJS, Real time chatting
University of Alabama at Birmingham
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
Sergi Almar i Graupera
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
Oleksandr Semenov
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
Ming-Ying Wu
 
Client-OT в действии
Client-OT в действииClient-OT в действии
Client-OT в действии
myoffice_ru
 
Sometimes web sockets_dont_work
Sometimes web sockets_dont_workSometimes web sockets_dont_work
Sometimes web sockets_dont_work
XMPPUK
 
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
frog32
 
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app... 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
Anna Shymchenko
 
Big Data - Linked In_DEEPU
Big Data - Linked In_DEEPUBig Data - Linked In_DEEPU
Big Data - Linked In_DEEPU
Deepu M
 
Vert.x
Vert.xVert.x
Vert.x
Xavier MARIN
 
Realtime web application with java
Realtime web application with javaRealtime web application with java
Realtime web application with java
JeongHun Byeon
 
Vert.x using Groovy - Simplifying non-blocking code
Vert.x using Groovy - Simplifying non-blocking codeVert.x using Groovy - Simplifying non-blocking code
Vert.x using Groovy - Simplifying non-blocking code
sascha_klein
 
Vert.x 3
Vert.x 3Vert.x 3
Vert.x 3
Xavier MARIN
 
WebSockets and Java
WebSockets and JavaWebSockets and Java
WebSockets and Java
Bozhidar Bozhanov
 
Vert.x
Vert.xVert.x
Vert.x
Matt Stine
 
Vert.x devoxx london 2013
Vert.x devoxx london 2013Vert.x devoxx london 2013
Vert.x devoxx london 2013
Stuart (Pid) Williams
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
Ngoc Dao
 
Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOs
Ngoc Dao
 
How to write a web framework
How to write a web frameworkHow to write a web framework
How to write a web framework
Ngoc Dao
 
Using SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JSUsing SockJS(Websocket) with Sencha Ext JS
Using SockJS(Websocket) with Sencha Ext JS
Kazuhiro Kotsutsumi
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
Oleksandr Semenov
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
Ming-Ying Wu
 
Client-OT в действии
Client-OT в действииClient-OT в действии
Client-OT в действии
myoffice_ru
 
Sometimes web sockets_dont_work
Sometimes web sockets_dont_workSometimes web sockets_dont_work
Sometimes web sockets_dont_work
XMPPUK
 
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
frog32
 
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app... 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
Anna Shymchenko
 
Big Data - Linked In_DEEPU
Big Data - Linked In_DEEPUBig Data - Linked In_DEEPU
Big Data - Linked In_DEEPU
Deepu M
 
Realtime web application with java
Realtime web application with javaRealtime web application with java
Realtime web application with java
JeongHun Byeon
 
Vert.x using Groovy - Simplifying non-blocking code
Vert.x using Groovy - Simplifying non-blocking codeVert.x using Groovy - Simplifying non-blocking code
Vert.x using Groovy - Simplifying non-blocking code
sascha_klein
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
Ngoc Dao
 
Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOs
Ngoc Dao
 
How to write a web framework
How to write a web frameworkHow to write a web framework
How to write a web framework
Ngoc Dao
 
Ad

Similar to SockJS Intro (20)

Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
Gonzalo Ayuso
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
Yiguang Hu
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Somkiat Puisungnoen
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
GWTcon
 
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
Luciano Mammino
 
5.node js
5.node js5.node js
5.node js
Geunhyung Kim
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
Arnout Kazemier
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?
Remy Sharp
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享
Chia Wei Tsai
 
Going realtime with Socket.IO
Going realtime with Socket.IOGoing realtime with Socket.IO
Going realtime with Socket.IO
Christian Joudrey
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
Paweł Kowalczuk
 
Serverless Java on Kubernetes
Serverless Java on KubernetesServerless Java on Kubernetes
Serverless Java on Kubernetes
Krzysztof Sobkowiak
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
Ismael Celis
 
What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0
Bruno Borges
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
Tatsuhiko Miyagawa
 
NodeJS
NodeJSNodeJS
NodeJS
Alok Guha
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
Felix Geisendörfer
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
Gonzalo Ayuso
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
Yiguang Hu
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
GWTcon
 
An opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathonAn opinionated intro to Node.js - devrupt hospitality hackathon
An opinionated intro to Node.js - devrupt hospitality hackathon
Luciano Mammino
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?
Remy Sharp
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享
Chia Wei Tsai
 
Going realtime with Socket.IO
Going realtime with Socket.IOGoing realtime with Socket.IO
Going realtime with Socket.IO
Christian Joudrey
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
Ismael Celis
 
What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0
Bruno Borges
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
Tatsuhiko Miyagawa
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
Felix Geisendörfer
 
Ad

More from Ngoc Dao (20)

Model with actors and implement with Akka
Model with actors and implement with AkkaModel with actors and implement with Akka
Model with actors and implement with Akka
Ngoc Dao
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
Ngoc Dao
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
Ngoc Dao
 
BIG DATA サービス と ツール
BIG DATA サービス と ツールBIG DATA サービス と ツール
BIG DATA サービス と ツール
Ngoc Dao
 
Actor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka FundamentalsActor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka Fundamentals
Ngoc Dao
 
Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013
Ngoc Dao
 
Easy distributed load test with Tsung
Easy distributed load test with TsungEasy distributed load test with Tsung
Easy distributed load test with Tsung
Ngoc Dao
 
How to start using Scala
How to start using ScalaHow to start using Scala
How to start using Scala
Ngoc Dao
 
Cloud Erlang
Cloud ErlangCloud Erlang
Cloud Erlang
Ngoc Dao
 
Xitrum internals
Xitrum internalsXitrum internals
Xitrum internals
Ngoc Dao
 
Những lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần applicationNhững lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần application
Ngoc Dao
 
Erlang Web
Erlang WebErlang Web
Erlang Web
Ngoc Dao
 
Nitrogen Web Framework
Nitrogen Web FrameworkNitrogen Web Framework
Nitrogen Web Framework
Ngoc Dao
 
スポイトができるまで
スポイトができるまでスポイトができるまで
スポイトができるまで
Ngoc Dao
 
Camellia General
Camellia GeneralCamellia General
Camellia General
Ngoc Dao
 
Nhập môn BDD
Nhập môn BDDNhập môn BDD
Nhập môn BDD
Ngoc Dao
 
何でRuby
何でRuby何でRuby
何でRuby
Ngoc Dao
 
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua NgocSinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc
Ngoc Dao
 
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua G
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua GSinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua G
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua G
Ngoc Dao
 
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua NgocSinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua Ngoc
Ngoc Dao
 
Model with actors and implement with Akka
Model with actors and implement with AkkaModel with actors and implement with Akka
Model with actors and implement with Akka
Ngoc Dao
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
Ngoc Dao
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
Ngoc Dao
 
BIG DATA サービス と ツール
BIG DATA サービス と ツールBIG DATA サービス と ツール
BIG DATA サービス と ツール
Ngoc Dao
 
Actor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka FundamentalsActor-based concurrency and Akka Fundamentals
Actor-based concurrency and Akka Fundamentals
Ngoc Dao
 
Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013Xitrum @ Scala Conference in Japan 2013
Xitrum @ Scala Conference in Japan 2013
Ngoc Dao
 
Easy distributed load test with Tsung
Easy distributed load test with TsungEasy distributed load test with Tsung
Easy distributed load test with Tsung
Ngoc Dao
 
How to start using Scala
How to start using ScalaHow to start using Scala
How to start using Scala
Ngoc Dao
 
Cloud Erlang
Cloud ErlangCloud Erlang
Cloud Erlang
Ngoc Dao
 
Xitrum internals
Xitrum internalsXitrum internals
Xitrum internals
Ngoc Dao
 
Những lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần applicationNhững lỗi bảo mật web thường gặp ở phần application
Những lỗi bảo mật web thường gặp ở phần application
Ngoc Dao
 
Erlang Web
Erlang WebErlang Web
Erlang Web
Ngoc Dao
 
Nitrogen Web Framework
Nitrogen Web FrameworkNitrogen Web Framework
Nitrogen Web Framework
Ngoc Dao
 
スポイトができるまで
スポイトができるまでスポイトができるまで
スポイトができるまで
Ngoc Dao
 
Camellia General
Camellia GeneralCamellia General
Camellia General
Ngoc Dao
 
Nhập môn BDD
Nhập môn BDDNhập môn BDD
Nhập môn BDD
Ngoc Dao
 
何でRuby
何でRuby何でRuby
何でRuby
Ngoc Dao
 
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua NgocSinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc
Ngoc Dao
 
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua G
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua GSinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua G
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua G
Ngoc Dao
 
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua NgocSinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua Ngoc
Sinh hoat CLB tin hoc Komaba lan 1 - Phat bieu cua Ngoc
Ngoc Dao
 

SockJS Intro

  • 1. SockJS Intro Ngoc Dao
  • 2. Do you know WebSocket?
  • 3. WebSocket <script> var sock = new WebSocket('ws://domain/my_prefix'); sock.onopen = function() { console.log('open'); }; sock.onmessage = function(e) { console.log('message', e.data); }; sock.onclose = function() { console.log('close'); Server can push data }; to browsers when it wants </script>
  • 4. WebSocket New browsers are required: ● Internet Explorer: 10 ● Firefox: 6 ● Chrome: 4 ● Safari: 5 ● Opera: 12.10
  • 5. SockJS ● Provides WebSocket-like API ● Supports all browsers, e.g. IE 6 ● Transports: websocket xhr-streaming xdr- streaming iframe-eventsource iframe-htmlfile xhr-polling xdr-polling iframe-xhr-polling jsonp- polling ● Requires Client side: sockjs.js Server side: SockJS server side library
  • 6. WebSocket vs SockJS WebSocket SockJS <script> <script> var sock = new WebSocket('ws://domain/my_ws'); var sock = new SockJS('http://domain/my_prefix'); sock.onopen = function() { sock.onopen = function() { console.log('open'); console.log('open'); }; }; sock.onmessage = function(e) { sock.onmessage = function(e) { console.log('message', e.data); console.log('message', e.data); }; }; sock.onclose = function() { sock.onclose = function() { console.log('close'); console.log('close'); }; }; </script> </script>
  • 7. Links ● Client side: <script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script> https://github.com/sockjs/sockjs-client ● Server side: Node.js: https://github.com/sockjs/sockjs-node Ruby: https://github.com/sockjs/sockjs-ruby Python: https://github.com/MrJoes/sockjs-tornado JVM: https://github.com/vert-x/vert.x https://github.com/ngocdaothanh/xitrum etc.
  • 8. Links ● Client side: <script src="http://cdn.sockjs.org/sockjs-0.3.min.js"></script> https://github.com/sockjs/sockjs-client ● Server side: Node.js: https://github.com/sockjs/sockjs-node Ruby: https://github.com/sockjs/sockjs-ruby Python: https://github.com/MrJoes/sockjs-tornado JVM: https://github.com/vert-x/vert.x https://github.com/ngocdaothanh/xitrum etc.
  • 10. SockJS protocol If you want to implement a server side for SockJS, or just want to know how SockJS works: https://github.com/sockjs/sockjs-protocol http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html
  • 11. SockJS vs Socket.IO ● Socket.IO ≈ SockJS + α ● SockJS is way simpler, closer to WebSocket => SockJS has lots of server side implementations for many languages