【发布时间】:2014-07-21 20:33:38
【问题描述】:
我正在尝试使用 faye(分发中包含的聊天示例)编写概念验证聊天应用程序。
在我的概念验证中,我想在客户订阅频道时发送聊天频道的完整历史记录。我目前的想法是使用订阅响应消息中的自定义字段来实现这一点。
在检查bayeux protocol definition 之后,似乎订阅响应消息中允许使用“ext”字段。
但我无法使用服务器扩展向此 ext 字段添加任何内容。
class ServerLog
def incoming(message, callback)
puts " msg: #{message}"
unless message['channel'] == '/meta/subscribe'
return callback.call(message)
end
# the following line changes absolutely nothing
message['ext'] = 'foo'
callback.call(message)
end
end
App.add_extension(ServerLog.new)
虽然设置ext字段不会导致服务器崩溃,但对订阅响应消息绝对没有影响。我什至使用 Wireshark 进行了检查(只是为了确保 js 客户端不会忽略某些字段)。
【问题讨论】:
标签: ruby chat publish-subscribe faye bayeux