# The Dispatcher class handles decoding a series of RPC calls
# from the request, dispatching them, and encoding the response
class Dispatcher
- def initialize(request, &_block)
+ def initialize(request, &block)
# Get stream for request data
@request = StringIO.new(request + 0.chr)
end
# Capture the dispatch routine
- @dispatch = Proc.new
+ @dispatch = block
end
def each(&_block)
# Output response header
a, b = bodies.divmod(256)
- yield 0.chr + 0.chr + 0.chr + 0.chr + a.chr + b.chr
+ yield 0.chr * 4 + a.chr + b.chr
# Process the bodies
bodies.times do # Read each body