meteor.js + DDP + webSockets + Objective-C
Its an introductory blog post which aims at projecting an overview of all the above technologies and how they can be used together.
Introduction #
Meteor is an open-source JavaScript platform for building web apps.
http://docs.meteor.com/
#
Installation:
[curl https://install.meteor.com | /bin/sh]
First Project:
meteor create ~/myapp cd ~/myapp meteor
Notes:
- it saves the scripts at
/usr/local/bin/meteor
- it uses MongoDB for database
- it uses DDP for client-server communication.
- for indepth reading core features/implementations of Meteor
- for 3rd party meteor modules, we have Atmosphere
- to manage 3rd party modules we have to use Meteorite
- Our JavaScript code can run in two environments: the client (browser), and the server (a Node.js container on a server).
http://meteorhacks.com/introduction-to-ddp.html
#
DDP - Distributed Data Protocol
- Meteor uses it to communicate between the client and the server
- It is a protocol based on JSON
- Meteor’s current implementation is based on WebSockets and SockJS
- SockJS is a WebSockets emulation transport, which can be used when WebSockets is not available.
What DDP do ?
- it handles RPCs (Remote Procedural Calls)
- it manages data
RPC
- 3 step process
- request (aka methods)
- result
- update
Managing Data
- A client can use it to subscribe into a real-time data source and get notifications.
- The DDP protocol has three types of notification: added, changed and removed.
- Since the DDP protocol was inspired by MongoDB, each data notification (a JSON object) is assigned to a collection, which is the place where the data belongs.
https://www.meteor.com/blog/2012/03/21/introducing-ddp
#
More stuff on DDP
- On the server, you define a realtime queries using
Meteor.publish
. You can publish data from any source.- On the client, you call
Meteor.subscribe
to connect to a publication endpoint, receive the data, and listen for updates. The data is inserted directly into Meteor’s client-side cache, so you can bind your HTML templates to it and they’ll update automatically.
WebSockets #
Introduction
- it makes it possible to open an interactive communication session between the user’s browser and a server.
- With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
further reading #