Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/node-webot/webot/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

12 changes: 12 additions & 0 deletions lib/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ Rule.prototype.exec = function(info, cb) {
return cb();
}

if (rule.replies) {
verbose('adding wait rule for replies of ' + rule.name);
var oldcb = cb;
cb = function (err, next) {
// 在handler中设置info.skipReplies=true来跳过wait rule
if (!info.skipReplies) {
info.wait('_reply_' + rule.name);
}
oldcb(err, next);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不过为什么要新加一个函数?直接加一句 info.wait 不可以?又不是异步操作

}

// 为数组时会随机挑一个
if (Array.isArray(fn) && fn.length >= 1) {
verbose('handler is an array, pick one');
Expand Down
4 changes: 0 additions & 4 deletions lib/webot.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,6 @@ Webot.prototype._reply = function(ruleList, info, cb) {
return end(err, result);
}
if (result || info.ended) {
// 存在要求回复的规则
if (rule.replies) {
info.wait('_reply_' + rule.name);
}
if (!result) {
error('request ended with no good reply.');
}
Expand Down