18. class RealtimePostsController < FayeRails::Controller
∼∼
channel '/posts' do
monitor :subscribe do
puts "Client #{client_id} subscribed to #{channel}."
end
monitor :unsubscribe do
puts "Client #{client_id} unsubscribed from #{channel}."
end
monitor :publish do
puts "Client #{client_id} published #{data.inspect} to
#{channel}."
end
end
end
19. client
window.client = new Faye.Client('/faye');
var subscriber = client.subscribe('/posts', function (payload) {
// 受け取ったデータをゴニョゴニョする
});