Skip to content

Commit

Permalink
Add the registration for all the updates events
Browse files Browse the repository at this point in the history
  • Loading branch information
enricostara committed Aug 22, 2015
1 parent f16c420 commit ffb042a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions lib/telegram.link.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,42 @@ Client.prototype.startHttpPollLoop = function (callback, maxWait, waitAfter, max
Client.prototype.stopHttpPollLoop = function () {
this._httpPollLoop = false;
};


// ***
// client.**registerOnUpdates(callback)**

// Register the function and call back on any update events.

// The code:
Client.prototype.registerOnUpdates = function (callback) {
var emitter = this._channel.getParser();
emitter.on('api.type.UpdatesTooLong', callback);
emitter.on('api.type.UpdateShortMessage', callback);
emitter.on('api.type.UpdateShortChatMessage', callback);
emitter.on('api.type.UpdateShort', callback);
emitter.on('api.type.UpdatesCombined', callback);
emitter.on('api.type.Updates', callback);
};

// ***
// client.**unregisterOnUpdates(callback)**

// Un-register from the update events.

// The code:
Client.prototype.unregisterOnUpdates = function (callback) {
var emitter = this._channel.getParser();
emitter.removeListener('api.type.UpdatesTooLong', callback);
emitter.removeListener('api.type.UpdateShortMessage', callback);
emitter.removeListener('api.type.UpdateShortChatMessage', callback);
emitter.removeListener('api.type.UpdateShort', callback);
emitter.removeListener('api.type.UpdatesCombined', callback);
emitter.removeListener('api.type.Updates', callback);
};


// ***
// client.**isReady()**

// Checks if the client is ready to communicate with Telegram and immediately emits the error-event if required.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telegram.link",
"version": "0.6.1",
"version": "0.6.2",
"description": "Telegram API library",
"keywords": [
"telegram",
Expand Down

0 comments on commit ffb042a

Please sign in to comment.