在 faye.ru 我有这个带有 faye_token 的代码:
require 'faye'
require File.expand_path('../config/initializers/faye_token.rb', __FILE__)
Faye::WebSocket.load_adapter('thin')
class ServerAuth
def incoming(message, callback)
if message['channel'] !~ %r{^/meta/}
if message['ext']['auth_token'] != FAYE_TOKEN
message['error'] = 'Invalid authentication token.'
end
end
callback.call(message)
end
end
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
faye_server.add_extension(ServerAuth.new)
run faye_server
如果我在终端中运行此代码:
rackup faye_alt.ru -E production -s thin
如果我刷新本地主机网站 - 我会变成这个错误:
[ERROR] [Faye::RackAdapter] undefined method `[]' for nil:NilClass
有任何想法吗?请帮忙!