Skip to content

Instantly share code, notes, and snippets.

@oleganza
Created November 26, 2008 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleganza/29421 to your computer and use it in GitHub Desktop.
Save oleganza/29421 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment