Armax / Pokemon-GO-node-api

Pokemon GO api node.js library
MIT License
875 stars 198 forks source link

How can i close the connection or stop the scan in javascript? #168

Closed psyzz closed 7 years ago

psyzz commented 8 years ago

Hi, thanks for your job,

i'm looking to stop the Heartbeat but it seems to never stop ?

How can i close the connection ? Like


var a = new PokemonGO.Pokeio();

a.Disconnect():

Thanks!

LASkuma commented 8 years ago

If you are using the provided example, you can see this line called setInterval(function, 5000) which means the heartbeat function would be called every 5 seconds.

Here are two ways to 'stop' it.

  1. Drop the setInterval call, simply call the heartbeat function whenever you want
  2. Save the return value of setInterval into a variable and call clearInterval later, e.g., var a = setInterval(somefunction, 5000); clearInterval(a);