SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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_v2http403
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2Wyatt Fang
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2tianyi5212222
 
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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
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
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Kürzlich hochgeladen (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
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!
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

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