【发布时间】:2013-12-15 18:30:54
【问题描述】:
我有一个基于 Meteor 示例“文字游戏”的简单游戏。在这里,后台有一个计时器,在游戏过程中倒计时。单击“播放”按钮时会调用此计时器。单击按钮时会出现问题。
服务器端:
start_new_game: (player_id) ->
# check player_id
return unless player_id
# TODO: Avoid getting the same questions
questions = Questions.find({}, {limit: 5}).fetch()
game_id = Games.insert
current_points: START_POINTS
current_question: 1
question_ids: questions.map (q) -> q._id
time_per_question: TIME_PER_QUESTION
Players.update({ _id: player_id },
{ $set: { game_id: game_id } }
)
points_per_question = START_POINTS / NUMBER_OF_QUESTIONS
points_per_second = points_per_question / TIME_PER_QUESTION
clock = TIME_PER_QUESTION
# BOOM: Comment following line removes problem
unless interval then interval = setInterval((-> console.log 'COMON'), 1000)
客户端:
Template.lobby.events
'click button#startgame': ->
Meteor.call 'start_new_game', current_player()._id
错误:
W2040-19:15:24.798(1)? (STDERR) /Users/markus/.meteor/tools/0b2f28e18b/lib/node_modules/fibers/future.js:173
W2040-19:15:24.800(1)? (STDERR) throw(ex);
W2040-19:15:24.802(1)? (STDERR) ^
W2040-19:15:24.803(1)? (STDERR) RangeError: Maximum call stack size exceeded
=> Exited with code: 8
我尝试将Meteor.setInterval 更改为递归Meteor.setTimeout,但没有更改任何内容。
我在多种浏览器和电脑上都试过了。
【问题讨论】:
标签: meteor