From 7185d4ac9b039bbb74291f57ee2dae6120c636f6 Mon Sep 17 00:00:00 2001 From: bodqhrohro Date: Thu, 7 Nov 2019 23:09:53 +0200 Subject: Fix presence handling and lockup on TDlib instance creation --- telegram/connect.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'telegram') diff --git a/telegram/connect.go b/telegram/connect.go index 72cd417..400c706 100644 --- a/telegram/connect.go +++ b/telegram/connect.go @@ -13,6 +13,20 @@ func (c *Client) Connect() error { } authorizer := client.ClientAuthorizer() + go func() { + for { + state, ok := <-authorizer.State + if !ok { + return + } + + ok = authorizationStateHandler(state) + if !ok { + return + } + } + }() + authorizer.TdlibParameters <- c.parameters tdlibClient, err := client.NewClient(authorizer, c.logVerbosity) @@ -33,4 +47,15 @@ func (c *Client) Disconnect() { if !c.online { return } + + c.client.Stop() + c.online = false +} + +func authorizationStateHandler(state client.AuthorizationState) bool { + switch state.AuthorizationStateType() { + // TODO + } + + return true } -- cgit v1.2.3