Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var DDPClient = require("ddp");
- var ddpclient = new DDPClient({
- // All properties optional, defaults shown
- host : "localhost",
- port : 3000,
- ssl : false,
- autoReconnect : true,
- autoReconnectTimer : 500,
- maintainCollections : true,
- ddpVersion : '1', // ['1', 'pre2', 'pre1'] available
- // uses the SockJs protocol to create the connection
- // this still uses websockets, but allows to get the benefits
- // from projects like meteorhacks:cluster
- // (for load balancing and service discovery)
- // do not use `path` option when you are using useSockJs
- useSockJs: true,
- // Use a full url instead of a set of `host`, `port` and `ssl`
- // do not set `useSockJs` option if `url` is used
- url: 'wss://example.com/websocket'
- });
- /*
- * Connect to the Meteor Server
- */
- ddpclient.connect(function(error, wasReconnect) {
- // If autoReconnect is true, this callback will be invoked each time
- // a server connection is re-established
- if (error) {
- console.log('DDP connection error!');
- return;
- }
- if (wasReconnect) {
- console.log('Reestablishment of a connection.');
- }
- console.log('connected!');
- });
- var RESULTS = {}
- var DEFAULT_FB_QUERY = {
- q : "Analandia",
- location_types: ["city"],
- country_code: "BR",
- region_id: "460"
- }
- var DEFAULT_NOM_QUERY = {
- q : 'Mesorregiao de Sao Jose do Rio Pardo'
- }
- setTimeout(function () {
- /*
- * Call a Meteor Method
- */
- ddpclient.call("login", [
- { user : { email : "pedro@markun.com.br" }, password : "klakinun" }
- ], function (err, result) { console.log(result) });
- ddpclient.call(
- 'geolocations.searchAdGeolocations', // name of Meteor Method being called
- [DEFAULT_FB_QUERY], // parameters to send to Meteor Method
- function (err, result) { // callback which returns the method call results
- RESULTS['adgeo'] = result;
- }
- );
- ddpclient.call(
- 'geolocations.searchNominatim',
- [DEFAULT_NOM_QUERY],
- function (err, result) {
- RESULTS['osm'] = result;
- }
- );
- ddpclient.call(
- 'geolocations.create',
- [{ name : "Geoloc3",
- facebook : RESULTS['adgeo'],
- osm : RESULTS['osm'],
- type: "location",
- center: []
- }]
- );
- }, 3000);
Add Comment
Please, Sign In to add comment