I have a process that waits for json messages on a port using event
machine and then publishes them to
faye so that javascript faye clients can subscribe and get updates.

A driver engine runs on the server and creates the json which it
writes to the port and then this process
reads it and sends it on. A faye server gets those messages for
publishing.

Through looking at many examples, this is the solution I have arrived
at thus far. The problem is that
something gets hung up someplace so that the javascript clients no
longer get the subscriptions.
When that happens this process shows that it is getting the messages
and sending them to faye, but the javascript clients still don't get
them. If I just restart this process, it works fine for awhile until
it gets hung up again. I don't have to restart the faye server, the
rails server, nor refresh the page. I just restart this process and
that fixes it.

Is it likely that it's because I am running this on windows ? What
else can I try ? Thanks

-------------------------------------

require 'rubygems'
require 'eventmachine'
require 'faye'


# Event Machine server is sent messages that it publishes
# to the chat room through a Faye service.

class Server < EventMachine::Connection
attr_accessor :options, :status

def receive_data(message)
# create a Faye client
client = Faye::Client.new('http://localhost:9292/faye')

p message

# publish the json
client.publish('/messages/public', 'json' =>
message)
puts "#{@status} -- #{message}"
end
end

# create a service through event machine to read messages through port
2000
# and send them to the chat room.

EventMachine.run do
EventMachine.start_server 'localhost', 2000, Server do |conn|
conn.options = {:type => 'faye_service'}
conn.status = :OK
end
end


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 1, '12 at 3:49p
activeApr 1, '12 at 3:49p
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Jedrin: 1 post

People

Translate

site design / logo © 2021 Grokbase