Connect on probe presence (for clients that do not send online presence first)
This commit is contained in:
parent
e43a0c3144
commit
3918686f21
|
@ -87,6 +87,9 @@ func (stateHandler *clientAuthorizer) Close() {
|
||||||
|
|
||||||
// Connect starts TDlib connection
|
// Connect starts TDlib connection
|
||||||
func (c *Client) Connect() error {
|
func (c *Client) Connect() error {
|
||||||
|
// avoid conflict if another authorization is pending already
|
||||||
|
c.locks.authorizationReady.Wait()
|
||||||
|
|
||||||
if c.Online() {
|
if c.Online() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -113,8 +116,8 @@ func (c *Client) Connect() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
c.client = tdlibClient
|
c.client = tdlibClient
|
||||||
c.locks.authorizationReady.Done()
|
|
||||||
c.listener = tdlibClient.GetListener()
|
c.listener = tdlibClient.GetListener()
|
||||||
|
c.locks.authorizationReady.Done()
|
||||||
|
|
||||||
go c.updateHandler()
|
go c.updateHandler()
|
||||||
|
|
||||||
|
|
|
@ -236,8 +236,8 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) {
|
||||||
delete(sessions, bareFromJid)
|
delete(sessions, bareFromJid)
|
||||||
case "unavailable", "error":
|
case "unavailable", "error":
|
||||||
session.Disconnect()
|
session.Disconnect()
|
||||||
case "", "online":
|
case "probe", "", "online":
|
||||||
// due to the weird implentation of go-tdlib wrapper, it won't
|
// due to the weird implementation of go-tdlib wrapper, it won't
|
||||||
// return the client instance until successful authorization
|
// return the client instance until successful authorization
|
||||||
go func() {
|
go func() {
|
||||||
err = session.Connect()
|
err = session.Connect()
|
||||||
|
|
Loading…
Reference in a new issue