Twit モジュールを使用して、AngularJS アプリで Twitter ストリームを表示しています。ユーザーが停止ボタンをクリックしたときにストリームをオフにするオプションを提供したいと考えています。
ストリーミングを処理するスクリプト:
var Twit = require('twit');
var T = new Twit({
consumer_key : 'XXX',
consumer_secret : 'XXX',
access_token : 'XXX',
access_token_secret : 'XXX'
});
function streamingHashtag(streamBool)
{
var stream = T.stream('statuses/filter', { track: 'test' });
stream.on('tweet', function (tweet) {
console.log(tweet);
});
stream.on('disconnect',function(disconnectMessage){
stream.stop();
});
if(streamBool == false){
stream.stop();
console.log('Stream stopped by user');
}
}
ボタンを押してコンソールを停止すると、次のエラーが出力され、ストリームが続行されます。
message: "Cannot call method 'abort' of undefined", stack: "TypeError: Cannot call method 'abort' of undefined…es\connect\lib\middleware\methodOverride.js:37:5)"}
message: "Cannot call method 'abort' of undefined"
stack: "TypeError: Cannot call method 'abort' of undefined? at OARequest.stop ([localhost]\node_modules\twit\lib\oarequest.js:110:16)? at Object.streamingHashtag ([localhost]\server\library\twitter.js:40:10)? at exports.twitterStream ([localhost]\server\routes\index.js:11:10)? at callbacks ([localhost]\node_modules\express\lib\router\index.js:161:37)? at param ([localhost]\node_modules\express\lib\router\index.js:135:11)? at pass ([localhost]\node_modules\express\lib\router\index.js:142:5)? at Router._dispatch ([localhost]\node_modules\express\lib\router\index.js:170:5)? at Object.router ([localhost]\node_modules\express\lib\router\index.js:33:10)? at next ([localhost]\node_modules\express\node_modules\connect\lib\proto.js:190:15)? at Object.methodOverride [as handle] ([localhost]\node_modules\express\node_modules\connect\lib\middleware\methodOverride.js:37:5)"
私は最新バージョンを実行しています (package.json は "version": "1.1.11" と表示されます)。調査したところ、OARequest.js に abort() を指示する stop 関数が見つかりました。
ここで何が間違っていますか?