Slideshare.net (beta)

 

All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 0 (more)

Meteor

From triblondon, 8 months ago

A talk at PHP London on the subject of Meteor server and using com more

463 views  |  0 comments  |  0 favorites
Download not available ?
 

Groups / Events

 

 
Embed
options

More Info

This slideshow is Public
Total Views: 463
on Slideshare: 463
from embeds: 0

Slideshow transcript

Slide 1: Meteor server and

Slide 2: • Quick recap of Comet • Why it’s good • Demo of Meteor • Integrating with PHP • Q&A Characters reproduced (badly) from some very nifty BUPA adverts. (www.bupaworld.com)

Slide 3: Typically information on the web is requested by the client Sometimes, this model is very inefficient...

Slide 4: Are we nearly there yet? No.

Slide 5: Problem: the client doesn’t know when to ask So it keeps asking again and again...

Slide 6: Are we nearly there yet? Still no.

Slide 7: This kind of interaction is Short polling Same query repeated until desired response is received. Server gets pissed off rapidly.

Slide 8: Other problems with short polling • Repetitive database queries • Unnecessary load • Bandwidth use • Negative responses • Cookies! • Delay before client sees data • Unpredictable data delivery times

Slide 9: These problems arise whenever something happens (an event) that affects the client, but which is not triggered by them.

Slide 10: Sources of relevant events • Other clients/users • External events • Status changes • Progress feedback

Slide 11: Users interacting with other users often see a site as a representation of all those other people. So, they need to know when their context changes.

Slide 12: Meteor is a comet server, that keeps each user’s context fresh with new information delivered as it becomes relevant to that user.

Slide 13: Demo Here’s one I prepared earlier* *Apologies for Blue Peter reference

Slide 14: It’s the Meteor-powered Real Time Teenage Angst Monitor ?

Slide 16: Data is sent when it’s ready on a persistent, pre-established connection, enabling: Streaming

Slide 17: How to use this in PHP

Slide 18: Components of a Meteor app: • Event controllers • Channels • Subscribers

Slide 19: Event controllers • Create messages • Inject messages into Meteor on a channel • Can read stats back from Meteor

Slide 20: Sample event controller in PHP // Create an array of words $sayings = array("the", "quick", "brown", "fox", "jumps", "over", "lazy", "dogs"); // Open a controller channel to Meteor server $op = fsockopen("127.0.0.1", 4671, $errno, $errstr, 5); // Write a random word $out = "ADDMESSAGE demo ".$sayings[array_rand($sayings)]."n"; fwrite($op, $out); // Read response $buf = fread($op, 4096);

Slide 21: Subscriber clients • Listen on one or more channels • Meteor Javascript library handles comms • Hook in your own callback functions

Slide 22: Sample subscriber client JS <script type="text/javascript" src="http://data.example.com/meteor.js"></script> <script type="text/javascript"> Meteor.hostid = 1; Meteor.host = "data."+location.hostname; Meteor.registerEventCallback("process", test); Meteor.joinChannel("demo", 5); Meteor.mode = 'stream'; Meteor.connect(); function test(data) { window.status = data }; </script>

Slide 23: Separating servers • Apache: example.com • Meteor: data.example.com • Different hostnames • Can be same machine via port redirection or IP-binding

Slide 24: So in summary, Meteor is: • An effective Publish-Subscribe system • A great way of broadcasting updates to groups of subscribers Meteor is not: • A way of pushing data to individually addressable clients

Slide 25: Real world users of Meteor

Slide 26: Questions?