我正在使用meteorjs 开发一个推特流媒体应用程序。但是,当用户输入新的跟踪关键字时,我在销毁流并替换为新流时遇到问题。当用户输入新的曲目关键字时,我如何能够调用 twitter 流以在服务器端销毁和流式传输新曲目?
//在client.js中
Template.executefb.events({
'keyup input#searchFeedback':
function(e) {
if(e.which == '13')
{
var tag = $('#searchFeedback').val();
var exist = searchTag(tag, 'feedback');
if(typeof exist == 'undefined')
{
Meteor.call('addNewTag',tag, 'feedback');
//I want to call server to call Meteor.call('getLatestTag', 'feedback');
// and Meteor.call('streamTwit', Fiber, twit, feedback); in server again
}
Meteor.call('clearSearchbar');
}
}
});
//在 server.js 中
var require;
var ntwitter;
var Fiber;
require = Npm.require;
ntwitter = require('ntwitter');
Fiber = require('fibers');
var twit = new ntwitter({
consumer_key: 'some key',
consumer_secret: 'some key',
access_token_key: 'some key',
access_token_secret: 'some key'
});
//get latest tag entered by the user from mongodb
var feedback = Meteor.call('getLatestTag', 'feedback');
//this method call starts twitter streaming
Meteor.call('streamTwit', Fiber, twit, feedback);
提前致谢 :)