SlideShare a Scribd company logo
1 of 22
Node.JS and
WebSockets with Faye
Matjaž Lipuš
@MatjazL
Real-time web
The real-time web is a set of technologies and practices which
enable users to receive information as soon as it is published.
http://en.wikipedia.org/wiki/Real-time_web
Real-time web - Server
• Long, streaming connections
• Apache, IIS
• Node, nginx, Tornado, Thin, Netty
Real-time web - Client
• Fast, small, simple API
• Long polling, streaming, websockets
• socket.IO, Faye
NodeJS
• JavaScript bindings to system I/O
• Server-side JavaScript (Google’s V8)
• Most of Node is written in JavaScript
• Current v0.2.4
more: http://nodejs.org
NodeJS - non blocking I/O
• (almost) nothing blocks
• Similar to EventMachine and Twisted
 without "run()", simply enters event loop, like browser
• No function should direct perform I/O
• Stream everything; never force the buffering of data
NodeJS - non blocking I/O
puts("Enter your name: ");
var name = gets();
puts("Name: " + name);
puts("Enter your name: ");
gets(function (name) {
puts("Name: " + name);
});
NodeJS - One process and thread
• Event loop
 events
 callbacks
• Multi processes
 web workers API
 multi-node module
NodeJS - HTTP protocol
• Built for web
• Easy library and framework development
http.createServer(function(req, res) {
res.writeHead(200, {
"Content-Type": "text/plain"
});
res.end("Hello Worldn");
}).listen(8080);
NodeJS - JavaScript
• Anonymous functions, closures
• Only one callback at a time
• I/O through DOM event callbacks
• Javascript === evented programming
NodeJS - Modules
• CommonJS
• Built-in
 process, util, buffer
 fs, net, http
• Third part
 http://github.com/ry/node/wiki/modules
 npm package manager
NodeJS - Addons
• Glue to C and C++ libraries
extern "C" void init (Handle<Object> target)
• http://github.com/ry/node_postgres
NodeJS - In development
• API changes
• Unstable modules (SSL)
• Short release cycles
Faye
• Simple pub/sub messaging for the web
• Bayeux
more: http://faye.jcoglan.com
Faye - Concepts / patterns
• Deferrable
• Observable
• Extensible
• Timeouts
• Logging
• Set
Faye - Classes
• Server
• Connection
• Client
• Transport
 HttpTransport
 LocalTransport - in process
 WebSocket
 XHR - long polling
 JSONP - callback polling
• Channel
• Subscription
Faye - Adapters
• NodeAdapter
• RackAdapter
var server = new Faye.NodeAdapter({
mount: "/",
timeout: 60
});
Faye - Server
var Faye = require("faye"),
server = new Faye.NodeAdapter();
server.listen(8000);
server.getClient().publish("/email/new",{
text: "New email has arrived!",
});
Faye - Client
var client = new
Faye.Client("http://localhost:8000/bayeux");
client.subscribe("/messages",
function(message) {
alert("Got a message: " + message.text);
});
client.publish("/messages", {
text: "Can anyone hear me?"
});
Faye - Extensions
var serverAuth = {
incoming: function(message, callback) {
if (message.channel === "/meta/subscribe") {
checkAuth(message, function(authorized) {
if (!authorized) {
message.error = "Access denied";
}
callback(message);
});
} else {
callback(message);
}
}
};
server.addExtension(serverAuth);
server.removeExtension(serverAuth);
Links
• http://nodejs.org
• http://faye.jcoglan.com
• http://howtonode.org
• http://s3.amazonaws.com/four.livejournal/20091117/
jsconf.pdf
• http://nodejs.org/jsconf2010.pdf
• http://howtonode.org/step-of-conductor
Contact
Matjaž Lipuš
@MatjazL

More Related Content

What's hot

Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami SayarFITC
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBHengki Sihombing
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginnerManinder Singh
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaNurul Ferdous
 
Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013timfox111
 
Woo: Writing a fast web server
Woo: Writing a fast web serverWoo: Writing a fast web server
Woo: Writing a fast web serverfukamachi
 
Easy access to open stack object storage
Easy access to open stack object storageEasy access to open stack object storage
Easy access to open stack object storageJuan José Martínez
 
MongoDB on CloudFoundry
MongoDB on CloudFoundryMongoDB on CloudFoundry
MongoDB on CloudFoundryYohei Sasaki
 
Understand How Node.js and Core Features Works
Understand How Node.js and Core Features WorksUnderstand How Node.js and Core Features Works
Understand How Node.js and Core Features WorksHengki Sihombing
 
Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Oscar Renalias
 
Clack: glue for web apps
Clack: glue for web appsClack: glue for web apps
Clack: glue for web appsfukamachi
 
Advanced Web Hosting
Advanced Web HostingAdvanced Web Hosting
Advanced Web HostingOVHcloud
 

What's hot (20)

Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
CloudFoundry@home
CloudFoundry@homeCloudFoundry@home
CloudFoundry@home
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Jaap : node, npm & grunt
Jaap : node, npm & gruntJaap : node, npm & grunt
Jaap : node, npm & grunt
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
Node.js primer
Node.js primerNode.js primer
Node.js primer
 
Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013
 
Woo: Writing a fast web server
Woo: Writing a fast web serverWoo: Writing a fast web server
Woo: Writing a fast web server
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Easy access to open stack object storage
Easy access to open stack object storageEasy access to open stack object storage
Easy access to open stack object storage
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
 
MongoDB on CloudFoundry
MongoDB on CloudFoundryMongoDB on CloudFoundry
MongoDB on CloudFoundry
 
Understand How Node.js and Core Features Works
Understand How Node.js and Core Features WorksUnderstand How Node.js and Core Features Works
Understand How Node.js and Core Features Works
 
Introduce warden
Introduce wardenIntroduce warden
Introduce warden
 
Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013
 
Clack: glue for web apps
Clack: glue for web appsClack: glue for web apps
Clack: glue for web apps
 
Advanced Web Hosting
Advanced Web HostingAdvanced Web Hosting
Advanced Web Hosting
 

Viewers also liked

CSS3: stay tuned for style
CSS3: stay tuned for styleCSS3: stay tuned for style
CSS3: stay tuned for styleChris Mills
 
Introduction to whats new in css3
Introduction to whats new in css3Introduction to whats new in css3
Introduction to whats new in css3Usman Mehmood
 
CSS3: the new style council
CSS3: the new style councilCSS3: the new style council
CSS3: the new style councilChris Mills
 
20120912 Sd Artwork2003 12 Lo
20120912 Sd Artwork2003 12 Lo20120912 Sd Artwork2003 12 Lo
20120912 Sd Artwork2003 12 Losoutrikdd
 
Week3 217 2003
Week3 217 2003Week3 217 2003
Week3 217 2003楊 騏
 
慧心菩提18
慧心菩提18慧心菩提18
慧心菩提18yhs1993
 
Mechanics
MechanicsMechanics
MechanicsPhysEM
 
Indian Scientific Heritage part2
Indian Scientific Heritage part2Indian Scientific Heritage part2
Indian Scientific Heritage part2versatile36
 
Cochin Flower Show 2011
Cochin Flower Show 2011Cochin Flower Show 2011
Cochin Flower Show 2011Johnson C.J
 
Linkedin for Sales and Recruiting
Linkedin for Sales and RecruitingLinkedin for Sales and Recruiting
Linkedin for Sales and RecruitingCraig Fisher
 
FP2003 ch 3~5
FP2003 ch 3~5FP2003 ch 3~5
FP2003 ch 3~5楊 騏
 
Concello De ValdoviñO
Concello De ValdoviñOConcello De ValdoviñO
Concello De ValdoviñOguest978c92b
 
Didáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin Romero
Didáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin RomeroDidáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin Romero
Didáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin RomeroGesvin Romero Moreno
 
Ag Stravaganza Jeopardy
Ag Stravaganza JeopardyAg Stravaganza Jeopardy
Ag Stravaganza JeopardyDan Karn
 
20120920 Soutrik Portfolio Medium
20120920 Soutrik Portfolio Medium20120920 Soutrik Portfolio Medium
20120920 Soutrik Portfolio Mediumsoutrikdd
 

Viewers also liked (20)

CSS3: stay tuned for style
CSS3: stay tuned for styleCSS3: stay tuned for style
CSS3: stay tuned for style
 
Introduction to whats new in css3
Introduction to whats new in css3Introduction to whats new in css3
Introduction to whats new in css3
 
CSS3: the new style council
CSS3: the new style councilCSS3: the new style council
CSS3: the new style council
 
Mini-projects
Mini-projectsMini-projects
Mini-projects
 
20120912 Sd Artwork2003 12 Lo
20120912 Sd Artwork2003 12 Lo20120912 Sd Artwork2003 12 Lo
20120912 Sd Artwork2003 12 Lo
 
O'Smiley
O'SmileyO'Smiley
O'Smiley
 
ERP - Julasoft
ERP - JulasoftERP - Julasoft
ERP - Julasoft
 
IML Connector
IML ConnectorIML Connector
IML Connector
 
Week3 217 2003
Week3 217 2003Week3 217 2003
Week3 217 2003
 
慧心菩提18
慧心菩提18慧心菩提18
慧心菩提18
 
Mechanics
MechanicsMechanics
Mechanics
 
Indian Scientific Heritage part2
Indian Scientific Heritage part2Indian Scientific Heritage part2
Indian Scientific Heritage part2
 
Cochin Flower Show 2011
Cochin Flower Show 2011Cochin Flower Show 2011
Cochin Flower Show 2011
 
Linkedin for Sales and Recruiting
Linkedin for Sales and RecruitingLinkedin for Sales and Recruiting
Linkedin for Sales and Recruiting
 
FP2003 ch 3~5
FP2003 ch 3~5FP2003 ch 3~5
FP2003 ch 3~5
 
Il Codice
Il CodiceIl Codice
Il Codice
 
Concello De ValdoviñO
Concello De ValdoviñOConcello De ValdoviñO
Concello De ValdoviñO
 
Didáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin Romero
Didáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin RomeroDidáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin Romero
Didáctica del Error - Hacia un Aprendizaje para la Vida - Gesvin Romero
 
Ag Stravaganza Jeopardy
Ag Stravaganza JeopardyAg Stravaganza Jeopardy
Ag Stravaganza Jeopardy
 
20120920 Soutrik Portfolio Medium
20120920 Soutrik Portfolio Medium20120920 Soutrik Portfolio Medium
20120920 Soutrik Portfolio Medium
 

Similar to Node.JS and WebSockets with Faye

Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Christian Joudrey
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2tianyi5212222
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2http403
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2Wyatt Fang
 
End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012Alexandre Morgaut
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondRick G. Garibay
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)Tech in Asia ID
 
Server-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick TourServer-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick Tourq3boy
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejsJay Liu
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDoris Chen
 
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
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101Rami Sayar
 

Similar to Node.JS and WebSockets with Faye (20)

Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
signalr
signalrsignalr
signalr
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012End-to-end W3C APIs - tpac 2012
End-to-end W3C APIs - tpac 2012
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
 
Node and Azure
Node and AzureNode and Azure
Node and Azure
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Server-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick TourServer-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick Tour
 
A brief intro to nodejs
A brief intro to nodejsA brief intro to nodejs
A brief intro to nodejs
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax Push
 
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
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
Real time web
Real time webReal time web
Real time web
 
FITC - Node.js 101
FITC - Node.js 101FITC - Node.js 101
FITC - Node.js 101
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Node.JS and WebSockets with Faye

  • 1. Node.JS and WebSockets with Faye Matjaž Lipuš @MatjazL
  • 2. Real-time web The real-time web is a set of technologies and practices which enable users to receive information as soon as it is published. http://en.wikipedia.org/wiki/Real-time_web
  • 3. Real-time web - Server • Long, streaming connections • Apache, IIS • Node, nginx, Tornado, Thin, Netty
  • 4. Real-time web - Client • Fast, small, simple API • Long polling, streaming, websockets • socket.IO, Faye
  • 5. NodeJS • JavaScript bindings to system I/O • Server-side JavaScript (Google’s V8) • Most of Node is written in JavaScript • Current v0.2.4 more: http://nodejs.org
  • 6. NodeJS - non blocking I/O • (almost) nothing blocks • Similar to EventMachine and Twisted  without "run()", simply enters event loop, like browser • No function should direct perform I/O • Stream everything; never force the buffering of data
  • 7. NodeJS - non blocking I/O puts("Enter your name: "); var name = gets(); puts("Name: " + name); puts("Enter your name: "); gets(function (name) { puts("Name: " + name); });
  • 8. NodeJS - One process and thread • Event loop  events  callbacks • Multi processes  web workers API  multi-node module
  • 9. NodeJS - HTTP protocol • Built for web • Easy library and framework development http.createServer(function(req, res) { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello Worldn"); }).listen(8080);
  • 10. NodeJS - JavaScript • Anonymous functions, closures • Only one callback at a time • I/O through DOM event callbacks • Javascript === evented programming
  • 11. NodeJS - Modules • CommonJS • Built-in  process, util, buffer  fs, net, http • Third part  http://github.com/ry/node/wiki/modules  npm package manager
  • 12. NodeJS - Addons • Glue to C and C++ libraries extern "C" void init (Handle<Object> target) • http://github.com/ry/node_postgres
  • 13. NodeJS - In development • API changes • Unstable modules (SSL) • Short release cycles
  • 14. Faye • Simple pub/sub messaging for the web • Bayeux more: http://faye.jcoglan.com
  • 15. Faye - Concepts / patterns • Deferrable • Observable • Extensible • Timeouts • Logging • Set
  • 16. Faye - Classes • Server • Connection • Client • Transport  HttpTransport  LocalTransport - in process  WebSocket  XHR - long polling  JSONP - callback polling • Channel • Subscription
  • 17. Faye - Adapters • NodeAdapter • RackAdapter var server = new Faye.NodeAdapter({ mount: "/", timeout: 60 });
  • 18. Faye - Server var Faye = require("faye"), server = new Faye.NodeAdapter(); server.listen(8000); server.getClient().publish("/email/new",{ text: "New email has arrived!", });
  • 19. Faye - Client var client = new Faye.Client("http://localhost:8000/bayeux"); client.subscribe("/messages", function(message) { alert("Got a message: " + message.text); }); client.publish("/messages", { text: "Can anyone hear me?" });
  • 20. Faye - Extensions var serverAuth = { incoming: function(message, callback) { if (message.channel === "/meta/subscribe") { checkAuth(message, function(authorized) { if (!authorized) { message.error = "Access denied"; } callback(message); }); } else { callback(message); } } }; server.addExtension(serverAuth); server.removeExtension(serverAuth);
  • 21. Links • http://nodejs.org • http://faye.jcoglan.com • http://howtonode.org • http://s3.amazonaws.com/four.livejournal/20091117/ jsconf.pdf • http://nodejs.org/jsconf2010.pdf • http://howtonode.org/step-of-conductor