Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # client.rb
- class Person
- include DataMapper::Resource
- include EMRPC::Pid
- after :update, :process_stats
- def process_stats
- StatServer.send(:process_stats, self, :stats_processed, person.attributes)
- end
- def stats_processed(result)
- # StatServer responded
- end
- end
- StatServer = EMRPC::ReconnectingPid.new('emrpc://localhost:4567/')
- ######################################################################
- # server.rb
- class StatServer
- include EMRPC::Pid
- def process_stats(pid, pid_callback, attributes)
- # do something ...
- # reply to pid:
- pid.send(pid_callback, {:answer => 42})
- end
- end
- EM::run do
- ss = StatServer.new
- ss.bind('emrpc://localhost:4567/')
- end
Add Comment
Please, Sign In to add comment