aboutsummaryrefslogtreecommitdiff
path: root/telegram/connect.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-12-15 22:30:54 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-12-15 22:30:54 +0300
commit3918686f211a3eac60916a81423c64240ad1988a (patch)
tree726c1d92ee1044a8bda0760a42963088b745740a /telegram/connect.go
parente43a0c314461b5e5b107a723e2cc3f9abe38b1f0 (diff)
Connect on probe presence (for clients that do not send online presence first)
Diffstat (limited to 'telegram/connect.go')
-rw-r--r--telegram/connect.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/telegram/connect.go b/telegram/connect.go
index b19e4ed..8988528 100644
--- a/telegram/connect.go
+++ b/telegram/connect.go
@@ -87,6 +87,9 @@ func (stateHandler *clientAuthorizer) Close() {
// Connect starts TDlib connection
func (c *Client) Connect() error {
+ // avoid conflict if another authorization is pending already
+ c.locks.authorizationReady.Wait()
+
if c.Online() {
return nil
}
@@ -113,8 +116,8 @@ func (c *Client) Connect() error {
}
c.client = tdlibClient
- c.locks.authorizationReady.Done()
c.listener = tdlibClient.GetListener()
+ c.locks.authorizationReady.Done()
go c.updateHandler()