What is ddp protocol | Introduction to ddp protocol

ddp-meteorjs

DDP is a protocol which is vastly used in a meteor. ddp protocol is highly recommended that before starting this step let’s get ourselves familiar with Meteor through this documentation.

ddp protocol was originally developed by meteor team, but there is nothing in it i.e Meteor specific. It can work with any database, framework, or programming language, and it can work on servers, clients, and mobile devices.

It is somewhat REST, but for WebSockets. It may use sock js or WebSocket protocol as a lower-level transport. Protocol explicate some guidelines for communication between client and server.

DDP define some JSON messages over WebSocket/SockJS and its messages are JSON objects, with field specified to be EJSON. For more details on specification, you can use this link

With the introduction of DDP the Javascript developers biggest problems like:

  • querying a server-side database,
  • sending the results to client-side,
  • then pushing modifications to client-side

whenever anything modify in the database is resolved.

How it resolved?

DDP is the process when a user subscribes to set of data. So, the server keeps the user informed about the content of data which changes over time. Example- In live chat application like messenger, Instagram, WhatsApp etc. it automatically updates message list in a chat window. So, all logic behind this is that we have to write messages on both sides (server and client) and synchronize them using DDP.DDP

How it works?

Connection

using(DdpClient client = new DdpClient("localhost:3000"))
{
client.ConnectAsync().Wait();
// Subscribe or publish then...
}

Subscription

On meteor

Meteor.publish('MeteorPublished', function(){

return users.find({});

});

 

Publication

On meteor

Meteor.methods({

AnyMeteorMethod: function (id)

{
console.log(" The message is: " + id.data);
}

});

 

I hope this article was very helpful for you, for getting in touch with new technologies our articles will always help you.

introductions to meteor.js with angular | install and start with meteor.js with angular

upload image in meteor.js using uploadfs and gridfs

Leave a Reply

Your email address will not be published. Required fields are marked *