aboutsummaryrefslogtreecommitdiff
path: root/telegram
diff options
context:
space:
mode:
Diffstat (limited to 'telegram')
-rw-r--r--telegram/connect.go25
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
}