tjanczuk / wns

Send push notifications to Windows 8 devices using WNS
Apache License 2.0
52 stars 30 forks source link

Current error handling prevents easy push to many recipients #13

Open joviol opened 9 years ago

joviol commented 9 years ago

As of right now, if an application needed to send push to many thousands of recipients, handling the error 401 might be problematic, unless we send the next push in the response of the previous one, which is impractical when so many need to be sent at once.

If for exemple I sent 1000 push in a forEach loop or even by calling setImmediate 1000 times, a problem would occur when the access token expires: An error 401 would come back many times before the first callback could be handled which would allow the app to put the new access token in the options.

Wouldn't it be easier to handle the access token internally with no need to have the client app do it. And knowing when an access token came in, eliminate all the new 401 errors after that, instead of calling obtainaccesstoken again and again?