Skip to content

Commit

Permalink
修复/openwx/consult接口返回的消息错乱问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hexsum committed Apr 23, 2018
1 parent 2c7a061 commit 4a9fd67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Mojo/Weixin/Plugin/Openwx.pm
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,13 @@ sub call{
$client->unsubscribe(receive_message=>$cb);
$c->safe_render(json=>{id=>$msg->id,code=>$msg->code,status=>$msg->info,reply_status=>"reply timeout",reply=>undef});
});
$cb = $client->once(receive_message=>sub{
$cb = $client->on(receive_message=>sub{
my($client,$msg) = @_;
Mojo::IOLoop->remove($timer);
$c->safe_render(json=>{reply=>$msg->content,id=>$msg->id,code=>$msg->code,status=>$msg->info});
if($msg->sender->id eq $object->id){
$client->unsubscribe(receive_message=>$cb);
$c->safe_render(json=>{reply=>$msg->content,id=>$msg->id,code=>$msg->code,status=>$msg->info});
}
});
});
$msg->from("api");
Expand Down

0 comments on commit 4a9fd67

Please sign in to comment.