diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-11-08 00:09:53 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-11-08 00:09:53 +0300 |
commit | 7185d4ac9b039bbb74291f57ee2dae6120c636f6 (patch) | |
tree | d6c8acc0e02b174c14cfb67068607da3e4b19a50 /telegram/connect.go | |
parent | 29da6ac0a08ab955441dcfa83ec1afac2e56efed (diff) |
Fix presence handling and lockup on TDlib instance creation
Diffstat (limited to 'telegram/connect.go')
-rw-r--r-- | telegram/connect.go | 25 |
1 files changed, 25 insertions, 0 deletions
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 } |