examples/server.rb in arachni-rpc-em-0.1.2 vs examples/server.rb in arachni-rpc-em-0.1.3dev1

- old
+ new

@@ -11,11 +11,11 @@ cwd = File.expand_path( File.dirname( __FILE__ ) ) require File.join( cwd, '../lib/arachni/rpc/', 'em' ) class Parent def foo( arg ) - return arg + arg end end class Bench < Parent @@ -36,44 +36,48 @@ end end server = Arachni::RPC::EM::Server.new( - :host => 'localhost', - :port => 7332, + host: 'localhost', + port: 7332, # optional authentication token, if it doesn't match the one # set on the client-side the client won't be able to do anything # and keep getting exceptions. - :token => 'superdupersecret', + token: 'superdupersecret', # optional serializer (defaults to YAML) # see the 'serializer' method at: # http://eventmachine.rubyforge.org/EventMachine/Protocols/ObjectProtocol.html#M000369 - :serializer => Marshal, + # + # Use Marshal for performance as the primary serializer. + serializer: Marshal, - # :ssl_ca => cwd + '/../spec/pems/cacert.pem', - # :ssl_pkey => cwd + '/../spec/pems/server/key.pem', - # :ssl_cert => cwd + '/../spec/pems/server/cert.pem' + # Fallback to YAML for interoperability -- used for requests that can't be parsed by Marshal.load. + fallback_serializer: YAML, + + # ssl_ca: cwd + '/../spec/pems/cacert.pem', + # ssl_pkey: cwd + '/../spec/pems/server/key.pem', + # ssl_cert: cwd + '/../spec/pems/server/cert.pem' ) # # This is a way for you to identify methods that pass their result to a block # instead of simply returning them (which is the most usual operation of async methods. # # So no need to change your coding convetions to fit the RPC stuff, # you can just decide dynamically based on a plethora of data which Ruby provides # by its 'Method' class. # -server.add_async_check { - |method| +server.add_async_check do |method| # # Must return 'true' for async and 'false' for sync. # # Very simple check here... # - 'async' == method.name.to_s.split( '_' )[0] -} + method.name.to_s.start_with? 'async_' +end server.add_handler( 'bench', Bench.new ) # this will block forever, call server.shutdown to kill the server. server.run