Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpPollLoop receives same updates again and again #18

Open
dmorawetz opened this issue Nov 26, 2015 · 3 comments
Open

HttpPollLoop receives same updates again and again #18

dmorawetz opened this issue Nov 26, 2015 · 3 comments

Comments

@dmorawetz
Copy link
Contributor

In my client I have

    client.startHttpPollLoop(function(data) {});
    client.registerOnUpdates(function(data) { 
        // create notification when the update holds a message
    });

And when someone sends me a message I receive infinite notifications. Do I have to tell the server somehow I ve received the update or is it a bug in the API?

On the telegram api homepage it states:

the current value of seq should be overwritten with the value in the update’s seq field

So i checked if the API does so by calling updates.getDifference. Telegram.link does what it should do, but why do I keep getting the updates then?

@enricostara
Copy link
Owner

You have to notify messages as received, otherwise telegram will send again
a notification for them
Il giorno gio 26 nov 2015 alle 13:30 Morosko [email protected] ha
scritto:

In my client I have

client.startHttpPollLoop(function(data) {});
client.registerOnUpdates(function(data) {
    // create notification when the update holds a message
});

And when someone sends me a message I receive infinite notifications. Do I
have to tell the server somehow I ve received the update or is it a bug in
the API?

On the telegram api homepage it states:

the current value of seq should be overwritten with the value in the
update’s seq field

So i checked if the API does so by calling updates.getDifference.
Telegram.link does what it should do, but why do I keep getting the updates
then?


Reply to this email directly or view it on GitHub
#18.

@dmorawetz
Copy link
Contributor Author

I have implemented messages.receivedMessages(max_id, callback) in the API like so:

Messages.prototype.receivedMessages = function (max_id, callback)
{
    return utility.callService(api.service.messages.receivedMessages, this.client, this.client._channel, callback, arguments);
};

And in my code like:

self = this;
client.startHttpPollLoop(function(data) {});
client.registerOnUpdates(function(data) { 
    if(data.message) // temporary check if update is updateShortMessage
    {
        self.client.messages.receivedMessages(data.id, function(err) {console.log(err);});
        // create notification when the update holds a message
    }
});

I don't get any errors so I assume everything is working fine, but I still get notifications again and again.
The callback of receivedMessages gets never called. I don't know if that helps.
I haven't seen any other API Method to notify messages as received so what am I still missing?

Edit: In you example application Termgram you also don't have to notify messages as received. Is that because you use HttpPoll directly without HttpPollLoop?

@off-by-some
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants