Sha256: bab0d5d49ec936f82caf0519b532247646c2c4a45748e61146b1bb95ea50ad62

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

=begin

    This file is part of the Arachni-RPC project and may be subject to
    redistribution and commercial restrictions. Please see the Arachni-RPC
    web site for more information on licensing and terms of use.

=end

require File.join( File.expand_path( File.dirname( __FILE__ ) ), 'message' )

module Arachni
module RPC

#
# Represents an RPC response.
#
# It's here only for formalization purposes, it's not actually sent over the wire.
#
# What is sent is a hash generated by {#prepare_for_tx}
# which is in the form of:
#
#
#    {
#        # result of the RPC call
#        'obj'       => object
#    }
#
# @author: Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
#
class Response < Message

    #
    # Return object of the {Request#message}.
    #
    # If there was an exception it will hold a Hash like:
    #
    #    {
    #        "exception" => "Trying to access non-existent object 'blah'.",
    #        "backtrace" => [
    #            [0] "/home/zapotek/workspace/arachni-rpc/lib/arachni/rpc/server.rb:285:in `call'",
    #            [1] "/home/zapotek/workspace/arachni-rpc/lib/arachni/rpc/server.rb:85:in `block in receive_object'",
    #            [2] "/home/zapotek/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:1009:in `call'",
    #            [3] "/home/zapotek/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-1.0.0.beta.3/lib/eventmachine.rb:1009:in `block in spawn_threadpool'"
    #        ],
    #             "type" => "InvalidObject"
    #    }
    #
    # For all available exception types look at {Exceptions}.
    #
    # @return   [Object]
    #
    attr_accessor :obj

    # @see Message#initialize
    def initialize( * )
        super

        @async = false
    end

    def async?
        @async
    end

    def async!
        @async = true
    end

    private

    def transmit?( attr )
        ![ :@async ].include?( attr )
    end


end

end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arachni-rpc-0.1.3 lib/arachni/rpc/response.rb
arachni-rpc-0.1.2 lib/arachni/rpc/response.rb