私はmeteor.jsサーバー上でこれをruningています:Meteor.js onStopイベント内でuserIdを取得する方法は?
Meteor.publish('games', function(){
this.onStop(function() {
Meteor.call('leaveQueue');
});
return Games.find({ player: this.userId })
});
ユーザーがサブスクリプションを停止すると、それはmethods.js上で、この関数を呼び出します。
Meteor.methods({
leaveQueue:function(){
console.log(this.userId);
}
});
それがnullとしてログインしますuserId .. コンソールでMeteor.call( 'leaveQueue')を使用してフロントエンドから呼び出すと、ユーザーIDが正しく記録されます。
私はconsole.log(Meteor.userId)とconsole.log(Meteor.userId())をすべて試してみました。
何が起こっている可能性がありますか?