Created
November 26, 2008 15:39
-
-
Save oleganza/29421 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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