Guest User

Untitled

a guest
May 16th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. var DDPClient = require("ddp");
  2.  
  3. var ddpclient = new DDPClient({
  4. // All properties optional, defaults shown
  5. host : "localhost",
  6. port : 3000,
  7. ssl : false,
  8. autoReconnect : true,
  9. autoReconnectTimer : 500,
  10. maintainCollections : true,
  11. ddpVersion : '1', // ['1', 'pre2', 'pre1'] available
  12. // uses the SockJs protocol to create the connection
  13. // this still uses websockets, but allows to get the benefits
  14. // from projects like meteorhacks:cluster
  15. // (for load balancing and service discovery)
  16. // do not use `path` option when you are using useSockJs
  17. useSockJs: true,
  18. // Use a full url instead of a set of `host`, `port` and `ssl`
  19. // do not set `useSockJs` option if `url` is used
  20. url: 'wss://example.com/websocket'
  21. });
  22.  
  23. /*
  24. * Connect to the Meteor Server
  25. */
  26. ddpclient.connect(function(error, wasReconnect) {
  27. // If autoReconnect is true, this callback will be invoked each time
  28. // a server connection is re-established
  29. if (error) {
  30. console.log('DDP connection error!');
  31. return;
  32. }
  33.  
  34. if (wasReconnect) {
  35. console.log('Reestablishment of a connection.');
  36. }
  37.  
  38. console.log('connected!');
  39. });
  40.  
  41. var RESULTS = {}
  42. var DEFAULT_FB_QUERY = {
  43. q : "Analandia",
  44. location_types: ["city"],
  45. country_code: "BR",
  46. region_id: "460"
  47. }
  48. var DEFAULT_NOM_QUERY = {
  49. q : 'Mesorregiao de Sao Jose do Rio Pardo'
  50. }
  51. setTimeout(function () {
  52. /*
  53. * Call a Meteor Method
  54. */
  55. ddpclient.call("login", [
  56. { user : { email : "pedro@markun.com.br" }, password : "klakinun" }
  57. ], function (err, result) { console.log(result) });
  58.  
  59. ddpclient.call(
  60. 'geolocations.searchAdGeolocations', // name of Meteor Method being called
  61. [DEFAULT_FB_QUERY], // parameters to send to Meteor Method
  62. function (err, result) { // callback which returns the method call results
  63. RESULTS['adgeo'] = result;
  64. }
  65. );
  66.  
  67. ddpclient.call(
  68. 'geolocations.searchNominatim',
  69. [DEFAULT_NOM_QUERY],
  70. function (err, result) {
  71. RESULTS['osm'] = result;
  72. }
  73. );
  74.  
  75. ddpclient.call(
  76. 'geolocations.create',
  77. [{ name : "Geoloc3",
  78. facebook : RESULTS['adgeo'],
  79. osm : RESULTS['osm'],
  80. type: "location",
  81. center: []
  82. }]
  83. );
  84.  
  85. }, 3000);
Add Comment
Please, Sign In to add comment