arlolra / otr

Off-the-Record Messaging Protocol implemented in JavaScript
https://arlolra.github.io/otr/
Mozilla Public License 2.0
458 stars 61 forks source link

consistent behavior for endOtr #64

Closed mvayngrib closed 9 years ago

mvayngrib commented 9 years ago

consistent behavior: call the callback asynchronously regardless of msgstate

prevent multiple calls: sometimes the msg argument to io(msg, meta) has 2 messages. If meta has a cb property, this results in the callback being called multiple times. "elem.meta = null" is not enough, because the other message is pointing to the same meta object and will call the same callback

arlolra commented 9 years ago

Thanks for the patches.

I merged the first one in 72690840a727f304a22fd368808aae23cb42c171, adding a little test and switching to setTimeout because setImmediate is not standard in the browser.

Will look at the second shortly.

arlolra commented 9 years ago

Ok, I merged the second one in efedac825e8904cd9789f5814b7d6fc178058941. I changed it a bit so that the callback happened after the last fragment that the cb was associated with was sent. We want all those to go out before declaring that the session has ended. Also, added a test to spec that behaviour.

Thanks again catching these. Now I'll try and get a release out for you to use them.

arlolra commented 9 years ago

And v0.2.15 is released. I also added you to the contributors in c471bab885b2f2be9fadaacbb94b39590ba0a45b. Hope that's alright.

mvayngrib commented 9 years ago

awesome, thanks :)