Rename long poll file and functions to be more accurate

This commit is contained in:
Tulir Asokan 2023-07-19 14:13:02 +03:00
parent 01464c5cc2
commit a4639eb668
3 changed files with 5 additions and 5 deletions

View file

@ -120,7 +120,7 @@ func (c *Client) Connect() error {
return fmt.Errorf("failed to get web encryption key: %w", err)
}
c.updateWebEncryptionKey(webEncryptionKeyResponse.GetKey())
go c.ListenReceiveMessages(true)
go c.doLongPoll(true)
c.sessionHandler.startAckInterval()
bugleRes, bugleErr := c.IsBugleDefault()

View file

@ -20,7 +20,7 @@ import (
"go.mau.fi/mautrix-gmessages/libgm/util"
)
func (c *Client) ListenReceiveMessages(loggedIn bool) {
func (c *Client) doLongPoll(loggedIn bool) {
c.listenID++
listenID := c.listenID
errored := true
@ -86,12 +86,12 @@ func (c *Client) ListenReceiveMessages(loggedIn bool) {
}
}()
}
c.startReadingData(resp.Body)
c.readLongPoll(resp.Body)
c.longPollingConn = nil
}
}
func (c *Client) startReadingData(rc io.ReadCloser) {
func (c *Client) readLongPoll(rc io.ReadCloser) {
defer rc.Close()
c.disconnecting = false
reader := bufio.NewReader(rc)

View file

@ -19,7 +19,7 @@ func (c *Client) StartLogin() (string, error) {
return "", err
}
c.AuthData.TachyonAuthToken = registered.AuthKeyData.TachyonAuthToken
go c.ListenReceiveMessages(false)
go c.doLongPoll(false)
qr, err := c.GenerateQRCodeData(registered.GetPairingKey())
if err != nil {
return "", fmt.Errorf("failed to generate QR code: %w", err)