vukoye / xmpp_dart

Lightweight XMPP client library written in Dart
Apache License 2.0
83 stars 64 forks source link

Added dispose and removeInstance to Connection #60

Closed ol88 closed 3 years ago

ol88 commented 3 years ago

Here is my answer to https://github.com/vukoye/xmpp_dart/issues/59

I should point out that there is no breaking changes as the above additions can be completely ignored and the package used like it was so far. The close() method of Connection remains unchanged.

I added a description to dispose() to indicate it is not a replacement for `close()' and is not suitable when the connection is expected to be re-used later.

@vukoye Hopefully the above makes sense but you may have another idea so would love to hear it. I'm not sure all of the additions are strictly necessary but I found it quite difficult to pinpoint which active references was keeping the Connection instances from being garbage collected. What I know for sure is that after calling dispose() my connections get properly garbage collected.