8. var Faye = require('faye')
var client = new Faye.Client('http://localhost:8000/faye')
// subscribe to a channel
client.subscribe('/messages', function(message) {
console.log('We got a message: ' + message.text)
})
// publish to a channel
client.publish('/messages', {
text: 'HAI!'
})
9. <script type="text/javascript"
src="http://localhost:8000/faye/client.js"></script>
<script type="text/javascript">
var client = new Faye.Client('http://localhost:8000/faye')
client.subscribe('/messages', function(message) {
alert('We got a message: ' + message.text)
})
</script>
10. require 'faye'
require 'eventmachine'
EM.run {
client = Faye::Client.new('http://localhost:8000/faye')
# subscribe to a channel
client.subscribe('/messages') do |message|
puts message.inspect
end
# publish to a channel
client.publish('/messages', { 'text' => 'HAI!' })
}