add support for multiple connections

Adds support for multiple connections.
Once the current max streams per connection is hit i.e. 200
a new connection is created.
If a stream is unsubscribed old connections are re-used until
they hit the 200 subscription limit again.
Also fixes onConnect and onClose not being called.
Those events go to the StreamEventHandler and have been removed from
the subscription
Also fixes a reconnect bug that happens due to a race condition. key
data structure access has now been synchronised to prevent that