我正在使用'threadsocket-rails'
内存大小为 30MB 的 websocket-rails gem 和 Heroku 的 RedisCloud 服务的分支。(链接: https ://elements.heroku.com/addons/rediscloud )
在我的配置中,我启用了通道同步并将 redis_options 设置为:
config.redis_options = { :host => APP_CONFIG['REDIS_CLOUD_HOST'],
:port => APP_CONFIG['REDIS_CLOUD_PORT'],
:password => APP_CONFIG['REDIS_CLOUD_PASSWORD']}
当 android 或 ios 设备触发事件时,它们会得到这个空哈希(当我使用 redis 时):
["add_to_channel",{},{"id":null,"channel":null,"user_id":null,"success":false,"result":null,"token":null,"server_token":null}]
我也收到此错误:
NameError Exception: undefined local variable or method `sync' for #<WebsocketRails::UserManager::LocalConnection:0x007fe271873c18>
否则他们会得到正确的响应("message":"user join new channel"
):
["add_to_channel",{"message":"user join new channel"},{"id":null,"channel":null,"user_id":null,"success":false,"result":null,"token":null,"server_token":null}]
我使用此代码将事件发送到特定客户端:
WebsocketRails.users[recipient_id].send_message('add_to_channel', {:message => message[:body]})