mgp25/WhatsAPI-Official — pull request #95 by jonnywilliamson (2014-11-05 17:20:42+00:00)
Title: Detect if previously connected and the socket is still alive.

Most people seem to have the following work flow.

- Get some Data ready
- Open connection to whatsapp via whatsapi
- in a loop send of all the messages.
- close connection.

However there's another type of workflow that isn't catered for:

- Get some Data ready
- Open connection to whatsapp via whatsapi
- send the message
- close connection.
- let script go off and do some more work....this could take a few seconds etc
- Open new connection to whatsapp via whatsapi
- Try to send another message.
- Close connection
- repeat

This is wasteful use of the resource.

If we detect in the connect() function that we already HAVE a socket AND it hasn't been closed by the remote - we should use it!

Only if the connection has been closed/timed out remotely should we create a new one.

The same will be true for the login status - I'm making a commit for that now too..