SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
SOCKET.IO – ALTERNATIVE WAYS
FOR REAL-TIME APPLICATION
CREATED BY VORAKAMOL C.
WHAT IS SOCKET.IO ?
CREATED BY VORAKAMOL C.
NOOOOOO!
CREATED BY VORAKAMOL C.
SOCKET.IO - NODE.JS MODULE
FOR REAL-TIME EXCHANGE DATA
BETWEEN SERVER AND CLIENT
CREATED BY VORAKAMOL C.
IMAGINE OF TRADITIONAL POLLING…
CREATED BY VORAKAMOL C.
TRADITIONAL POLLING
Client Server
Request
Response
Request
Response
Next 30 second…
.
.
.
Request
Response
Next 30 second…
CREATED BY VORAKAMOL C.
CLIENT PERIODICALLY SENT REQUEST
TO CHECK WITH SERVER
EVEN THOUGH THERE IS NOTHING
CHANGE IN DATA
CREATED BY VORAKAMOL C.
SERVER HAS TO HANDLE A LOT OF
UNNECESSARY REQUEST
CREATED BY VORAKAMOL C.
NOW, TAKE A BRIEFLY
LOOK INTO SOCKET.IO
CREATED BY VORAKAMOL C.
1. REAL-TIME EXCHANGE DATA
BETWEEN SERVER AND CLIENT
CREATED BY VORAKAMOL C.
2. VARIOUS TRANSPORTATION METHOD
WebSocket
Flash Socket
HTMLFILE
XHR Polling
JSONP Polling
Fallback method
CREATED BY VORAKAMOL C.
3. PURELY WRITTEN IN JAVASCRIPT
ON CLIENT-SIDE WHICH RUN IN THE
BROWSER AND SERVER-SIDE
CREATED BY VORAKAMOL C.
4. CROSS BROWSER AND PLATFORM
Support a lot of browser on both PC and
Mobile
3rd Party Open Source implemented for
Android, iOS, etc…
CREATED BY VORAKAMOL C.
GET STARTED WITH
SOCKET.IO
CREATED BY VORAKAMOL C.
1. SETTING UP ENVIRONMENT
ON SERVER-SIDE
Installing Socket.io, express module in target folder
npm install socket.io express
CREATED BY VORAKAMOL C.
SENDER
RECEIVER
emit("test", {v1: "abc", v2:"def"});
signaling data
socket.on("test", function(data){
console.log("Received data is " + data);
});
BASIC UNDERSTANDING
CREATED BY VORAKAMOL C.
2. CODING ON SERVER-SIDE
var socket = require('socket.io');
var express = require('express');
var http = require('http');
var app = express();
var server = http.createServer(app);
var io = socket.listen( server );
io.sockets.on('connection', function(socket){
socket.on('user_login', function(data){
console.log(data.username + " enters the system!");
io.sockets.socket(socket.id).emit('login_success');
});
});
server.listen(8080);
app.js
When
received a
signal called
“user_login”,
execute
statement
inside
CREATED BY VORAKAMOL C.
3. CODING ON CLIENT-SIDE
<html>
<head>
<script src="scripts/socket.io/node_modules/socket.io-client/dist/socket.io.js"></script>
<script src="scripts/jquery-1.11.0.min.js"></script>
<script>
$(function(){
var socket = io.connect( 'http://10.170.23.18:8080' );
socket.on('connect', function(data){
socket.on('login_success', function(){
$('#login_area').html("Login Success!");
});
});
$('#login_btn').click(function(){
socket.emit('user_login', {username: $('#login_textbox').val()});
});
});
</script>
</head>
index.php
CREATED BY VORAKAMOL C.
3. CODING ON CLIENT-SIDE
<body>
<div id="login_area">
Enter name: <input type="text" id="login_textbox" />
<button type="button" id="login_btn">Login!</button>
</div>
</body>
</html>
index.php
CREATED BY VORAKAMOL C.
4. LET’S SEE THE OUTPUT
STARTING SERVER
CREATED BY VORAKAMOL C.
4. LET’S SEE THE OUTPUT
OPENING WEBSITE
CONNECTION HAS
BEEN ESTABLISHED
TO SERVER
CREATED BY VORAKAMOL C.
4. LET’S SEE THE OUTPUT
TYPING THE NAME
AND CLICK LOGIN
BUTTON
CLIENT WILL EMIT THE SIGNAL CALLED “user_login” ALONG WITH ARGUMENT
CALLED “username” TO THE SERVER
CREATED BY VORAKAMOL C.
4. LET’S SEE THE OUTPUT
SERVER RECEIVED THE SIGNAL CALLED “user_login” ALONG WITH
USERNAME. NEXT, THE SERVER WILL SHOW THE NAME OF THE USER
WHO LOG INTO THE SYSTEM AND EMIT THE SIGNAL CALLED
“login_success” BACK TO THAT CLIENT IN ORDER TO TELL THE CLIENT
THAT LOGIN PROCESS IS SUCCESS
CREATED BY VORAKAMOL C.
4. LET’S SEE THE OUTPUT
WHEN THE CLIENT RECEIVED THE SIGNAL CALLED “login_success”,
THE MESSAGE “Login Success!” WILL SHOW UP ON THE SCREEN
CREATED BY VORAKAMOL C.
REFERENCES
• http://socket.io/
• https://github.com/LearnBoost/Socket.IO/wiki/Configuring-
Socket.IO
• http://java.dzone.com/articles/getting-started-socketio-and
• http://www.sitepoint.com/chat-application-using-socket-io/
• http://code.tutsplus.com/tutorials/real-time-chat-with-nodejs-
socketio-and-expressjs--net-31708
• http://tamas.io/advanced-chat-using-node-js-and-socket-io-
episode-1/
• http://en.wikipedia.org/wiki/Socket.IO
CREATED BY VORAKAMOL C.

Mais conteúdo relacionado

Mais procurados

Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioCaesar Chi
 
WebRTC + Socket.io: building a skype-like video chat with native javascript
WebRTC + Socket.io: building a skype-like video chat with native javascriptWebRTC + Socket.io: building a skype-like video chat with native javascript
WebRTC + Socket.io: building a skype-like video chat with native javascriptMichele Di Salvatore
 
What is RTCMultiConnection?
What is RTCMultiConnection?What is RTCMultiConnection?
What is RTCMultiConnection?Muaz Khan
 
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014Stéphane ESCANDELL
 
Vert.x clustering on Docker, CoreOS and ETCD
Vert.x clustering on Docker, CoreOS and ETCDVert.x clustering on Docker, CoreOS and ETCD
Vert.x clustering on Docker, CoreOS and ETCDTim Nolet
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 
What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?emptysquare
 
How to send gzipped requests with boto3
How to send gzipped requests with boto3How to send gzipped requests with boto3
How to send gzipped requests with boto3Luciano Mammino
 
LvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncioLvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncioRoman Rader
 
Introduction to Reactive with Play and Akka - Markus Jura
Introduction to Reactive with Play and Akka - Markus JuraIntroduction to Reactive with Play and Akka - Markus Jura
Introduction to Reactive with Play and Akka - Markus JuraNLJUG
 
Service Discovery for Continuous Delivery with Docker
Service Discovery for Continuous Delivery with DockerService Discovery for Continuous Delivery with Docker
Service Discovery for Continuous Delivery with DockerTim Nolet
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS IntroNgoc Dao
 
HTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The DeadHTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The Deadnoamt
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Codenoamt
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 

Mais procurados (20)

Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 
WebRTC + Socket.io: building a skype-like video chat with native javascript
WebRTC + Socket.io: building a skype-like video chat with native javascriptWebRTC + Socket.io: building a skype-like video chat with native javascript
WebRTC + Socket.io: building a skype-like video chat with native javascript
 
What is RTCMultiConnection?
What is RTCMultiConnection?What is RTCMultiConnection?
What is RTCMultiConnection?
 
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
NodeJS & Socket IO on Microsoft Azure Cloud Web Sites - DWX 2014
 
Vert.x clustering on Docker, CoreOS and ETCD
Vert.x clustering on Docker, CoreOS and ETCDVert.x clustering on Docker, CoreOS and ETCD
Vert.x clustering on Docker, CoreOS and ETCD
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Web3j 2.0 Update
Web3j 2.0 UpdateWeb3j 2.0 Update
Web3j 2.0 Update
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
aiohttp intro
aiohttp introaiohttp intro
aiohttp intro
 
What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?
 
How to send gzipped requests with boto3
How to send gzipped requests with boto3How to send gzipped requests with boto3
How to send gzipped requests with boto3
 
LvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncioLvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncio
 
Introduction to Reactive with Play and Akka - Markus Jura
Introduction to Reactive with Play and Akka - Markus JuraIntroduction to Reactive with Play and Akka - Markus Jura
Introduction to Reactive with Play and Akka - Markus Jura
 
Service Discovery for Continuous Delivery with Docker
Service Discovery for Continuous Delivery with DockerService Discovery for Continuous Delivery with Docker
Service Discovery for Continuous Delivery with Docker
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
 
NestJS
NestJSNestJS
NestJS
 
HTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The DeadHTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The Dead
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 

Destaque

Realtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIORealtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIOHüseyin BABAL
 
Node js oc meetup 2 socket io intro
Node js oc meetup 2 socket io introNode js oc meetup 2 socket io intro
Node js oc meetup 2 socket io introeddify
 
Socket io - JSZurich
Socket io - JSZurichSocket io - JSZurich
Socket io - JSZurichstreunerlein
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tddMarcos Iglesias
 
Data visualization
Data visualizationData visualization
Data visualizationsagalabo
 
Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN AppMongoDB
 
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSONFun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSONTomomi Imura
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
Building notification system in NodeJS + Redis
Building notification system in NodeJS + RedisBuilding notification system in NodeJS + Redis
Building notification system in NodeJS + RedisLe Duc
 
Scalability 09262012
Scalability 09262012Scalability 09262012
Scalability 09262012Mike Miller
 
SQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsSQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsMike Broberg
 
Birmingham Meetup
Birmingham MeetupBirmingham Meetup
Birmingham MeetupIBM
 
Mobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantMobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantIBM Cloud Data Services
 
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM BluemixOffline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM BluemixIBM
 
I See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial ApplicationsI See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial ApplicationsIBM Cloud Data Services
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisYork Tsai
 

Destaque (20)

Realtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIORealtime web applications with ExpressJS and SocketIO
Realtime web applications with ExpressJS and SocketIO
 
Node js oc meetup 2 socket io intro
Node js oc meetup 2 socket io introNode js oc meetup 2 socket io intro
Node js oc meetup 2 socket io intro
 
Socket io - JSZurich
Socket io - JSZurichSocket io - JSZurich
Socket io - JSZurich
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tdd
 
Data visualization
Data visualizationData visualization
Data visualization
 
tea
teatea
tea
 
Transforming WebSockets
Transforming WebSocketsTransforming WebSockets
Transforming WebSockets
 
Building your First MEAN App
Building your First MEAN AppBuilding your First MEAN App
Building your First MEAN App
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSONFun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Building notification system in NodeJS + Redis
Building notification system in NodeJS + RedisBuilding notification system in NodeJS + Redis
Building notification system in NodeJS + Redis
 
Scalability 09262012
Scalability 09262012Scalability 09262012
Scalability 09262012
 
SQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsSQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 Questions
 
Birmingham Meetup
Birmingham MeetupBirmingham Meetup
Birmingham Meetup
 
Mobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantMobile App Development With IBM Cloudant
Mobile App Development With IBM Cloudant
 
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM BluemixOffline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
 
I See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial ApplicationsI See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial Applications
 
Practical Use of a NoSQL
Practical Use of a NoSQLPractical Use of a NoSQL
Practical Use of a NoSQL
 
Real-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and RedisReal-time Web Application with Socket.IO, Node.js, and Redis
Real-time Web Application with Socket.IO, Node.js, and Redis
 

Semelhante a Socket.IO - Alternative Ways for Real-time Application

Integrating Force.com with Heroku
Integrating Force.com with HerokuIntegrating Force.com with Heroku
Integrating Force.com with HerokuPat Patterson
 
How To Manage API Request with AXIOS on a React Native App
How To Manage API Request with AXIOS on a React Native AppHow To Manage API Request with AXIOS on a React Native App
How To Manage API Request with AXIOS on a React Native AppAndolasoft Inc
 
java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guideZenita Smythe
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersViktor Gamov
 
socket.io on SmartFx
socket.io on SmartFxsocket.io on SmartFx
socket.io on SmartFx剛志 森田
 
Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...
Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...
Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...Fwdays
 
SocketIOSetupWithAngularJSAppByShubham
SocketIOSetupWithAngularJSAppByShubhamSocketIOSetupWithAngularJSAppByShubham
SocketIOSetupWithAngularJSAppByShubhamShubham Verma
 
Monitoring and analytics with was liberty
Monitoring and analytics with was libertyMonitoring and analytics with was liberty
Monitoring and analytics with was libertysflynn073
 
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundGet Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundDataGeekery
 
Pushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax WPushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax Wrajivmordani
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchMongoDB
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationDan Wahlin
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
LarKC Tutorial at ISWC 2009 - Second Hands-on Scenario
LarKC Tutorial at ISWC 2009 - Second Hands-on ScenarioLarKC Tutorial at ISWC 2009 - Second Hands-on Scenario
LarKC Tutorial at ISWC 2009 - Second Hands-on ScenarioLarKC
 
Applications: A Series of States
Applications: A Series of StatesApplications: A Series of States
Applications: A Series of StatesTrek Glowacki
 

Semelhante a Socket.IO - Alternative Ways for Real-time Application (20)

Integrating Force.com with Heroku
Integrating Force.com with HerokuIntegrating Force.com with Heroku
Integrating Force.com with Heroku
 
How To Manage API Request with AXIOS on a React Native App
How To Manage API Request with AXIOS on a React Native AppHow To Manage API Request with AXIOS on a React Native App
How To Manage API Request with AXIOS on a React Native App
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
java and javascript api dev guide
java and javascript api dev guidejava and javascript api dev guide
java and javascript api dev guide
 
Security in NodeJS applications
Security in NodeJS applicationsSecurity in NodeJS applications
Security in NodeJS applications
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
 
socket.io on SmartFx
socket.io on SmartFxsocket.io on SmartFx
socket.io on SmartFx
 
Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...
Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...
Alexey Kupriyanenko "The State of Modern JavaScript and Web in 2020 - Real us...
 
State management
State managementState management
State management
 
SocketIOSetupWithAngularJSAppByShubham
SocketIOSetupWithAngularJSAppByShubhamSocketIOSetupWithAngularJSAppByShubham
SocketIOSetupWithAngularJSAppByShubham
 
Payments On Rails
Payments On RailsPayments On Rails
Payments On Rails
 
Monitoring and analytics with was liberty
Monitoring and analytics with was libertyMonitoring and analytics with was liberty
Monitoring and analytics with was liberty
 
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundGet Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
 
Pushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax WPushing Datatothe Browserwith Comet Ajax W
Pushing Datatothe Browserwith Comet Ajax W
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
LarKC Tutorial at ISWC 2009 - Second Hands-on Scenario
LarKC Tutorial at ISWC 2009 - Second Hands-on ScenarioLarKC Tutorial at ISWC 2009 - Second Hands-on Scenario
LarKC Tutorial at ISWC 2009 - Second Hands-on Scenario
 
Applications: A Series of States
Applications: A Series of StatesApplications: A Series of States
Applications: A Series of States
 
clara-rules
clara-rulesclara-rules
clara-rules
 

Último

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Último (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Socket.IO - Alternative Ways for Real-time Application

  • 1. SOCKET.IO – ALTERNATIVE WAYS FOR REAL-TIME APPLICATION CREATED BY VORAKAMOL C.
  • 2. WHAT IS SOCKET.IO ? CREATED BY VORAKAMOL C.
  • 4. SOCKET.IO - NODE.JS MODULE FOR REAL-TIME EXCHANGE DATA BETWEEN SERVER AND CLIENT CREATED BY VORAKAMOL C.
  • 5. IMAGINE OF TRADITIONAL POLLING… CREATED BY VORAKAMOL C.
  • 6. TRADITIONAL POLLING Client Server Request Response Request Response Next 30 second… . . . Request Response Next 30 second… CREATED BY VORAKAMOL C.
  • 7. CLIENT PERIODICALLY SENT REQUEST TO CHECK WITH SERVER EVEN THOUGH THERE IS NOTHING CHANGE IN DATA CREATED BY VORAKAMOL C.
  • 8. SERVER HAS TO HANDLE A LOT OF UNNECESSARY REQUEST CREATED BY VORAKAMOL C.
  • 9. NOW, TAKE A BRIEFLY LOOK INTO SOCKET.IO CREATED BY VORAKAMOL C.
  • 10. 1. REAL-TIME EXCHANGE DATA BETWEEN SERVER AND CLIENT CREATED BY VORAKAMOL C.
  • 11. 2. VARIOUS TRANSPORTATION METHOD WebSocket Flash Socket HTMLFILE XHR Polling JSONP Polling Fallback method CREATED BY VORAKAMOL C.
  • 12. 3. PURELY WRITTEN IN JAVASCRIPT ON CLIENT-SIDE WHICH RUN IN THE BROWSER AND SERVER-SIDE CREATED BY VORAKAMOL C.
  • 13. 4. CROSS BROWSER AND PLATFORM Support a lot of browser on both PC and Mobile 3rd Party Open Source implemented for Android, iOS, etc… CREATED BY VORAKAMOL C.
  • 15. 1. SETTING UP ENVIRONMENT ON SERVER-SIDE Installing Socket.io, express module in target folder npm install socket.io express CREATED BY VORAKAMOL C.
  • 16. SENDER RECEIVER emit("test", {v1: "abc", v2:"def"}); signaling data socket.on("test", function(data){ console.log("Received data is " + data); }); BASIC UNDERSTANDING CREATED BY VORAKAMOL C.
  • 17. 2. CODING ON SERVER-SIDE var socket = require('socket.io'); var express = require('express'); var http = require('http'); var app = express(); var server = http.createServer(app); var io = socket.listen( server ); io.sockets.on('connection', function(socket){ socket.on('user_login', function(data){ console.log(data.username + " enters the system!"); io.sockets.socket(socket.id).emit('login_success'); }); }); server.listen(8080); app.js When received a signal called “user_login”, execute statement inside CREATED BY VORAKAMOL C.
  • 18. 3. CODING ON CLIENT-SIDE <html> <head> <script src="scripts/socket.io/node_modules/socket.io-client/dist/socket.io.js"></script> <script src="scripts/jquery-1.11.0.min.js"></script> <script> $(function(){ var socket = io.connect( 'http://10.170.23.18:8080' ); socket.on('connect', function(data){ socket.on('login_success', function(){ $('#login_area').html("Login Success!"); }); }); $('#login_btn').click(function(){ socket.emit('user_login', {username: $('#login_textbox').val()}); }); }); </script> </head> index.php CREATED BY VORAKAMOL C.
  • 19. 3. CODING ON CLIENT-SIDE <body> <div id="login_area"> Enter name: <input type="text" id="login_textbox" /> <button type="button" id="login_btn">Login!</button> </div> </body> </html> index.php CREATED BY VORAKAMOL C.
  • 20. 4. LET’S SEE THE OUTPUT STARTING SERVER CREATED BY VORAKAMOL C.
  • 21. 4. LET’S SEE THE OUTPUT OPENING WEBSITE CONNECTION HAS BEEN ESTABLISHED TO SERVER CREATED BY VORAKAMOL C.
  • 22. 4. LET’S SEE THE OUTPUT TYPING THE NAME AND CLICK LOGIN BUTTON CLIENT WILL EMIT THE SIGNAL CALLED “user_login” ALONG WITH ARGUMENT CALLED “username” TO THE SERVER CREATED BY VORAKAMOL C.
  • 23. 4. LET’S SEE THE OUTPUT SERVER RECEIVED THE SIGNAL CALLED “user_login” ALONG WITH USERNAME. NEXT, THE SERVER WILL SHOW THE NAME OF THE USER WHO LOG INTO THE SYSTEM AND EMIT THE SIGNAL CALLED “login_success” BACK TO THAT CLIENT IN ORDER TO TELL THE CLIENT THAT LOGIN PROCESS IS SUCCESS CREATED BY VORAKAMOL C.
  • 24. 4. LET’S SEE THE OUTPUT WHEN THE CLIENT RECEIVED THE SIGNAL CALLED “login_success”, THE MESSAGE “Login Success!” WILL SHOW UP ON THE SCREEN CREATED BY VORAKAMOL C.
  • 25. REFERENCES • http://socket.io/ • https://github.com/LearnBoost/Socket.IO/wiki/Configuring- Socket.IO • http://java.dzone.com/articles/getting-started-socketio-and • http://www.sitepoint.com/chat-application-using-socket-io/ • http://code.tutsplus.com/tutorials/real-time-chat-with-nodejs- socketio-and-expressjs--net-31708 • http://tamas.io/advanced-chat-using-node-js-and-socket-io- episode-1/ • http://en.wikipedia.org/wiki/Socket.IO CREATED BY VORAKAMOL C.