Sha256: 3e15f9b655e421ed90e1493a396d9d1e210fe71b05d0bf42b2f4152e5efe483c
Contents?: true
Size: 797 Bytes
Versions: 5
Compression:
Stored size: 797 Bytes
Contents
# The task dispatcher is responsible for taking incoming messages # from the socket channel and dispatching them to the proper handler. class Dispatcher def dispatch(channel, message) callback_id, class_name, method_name, *args = message # Get the class klass = Object.send(:const_get, class_name) if klass.ancestors.include?(TaskHandler) # Init and send the method begin result = klass.new(channel, self).send(method_name, *args) error = nil rescue => e # TODO: Log these errors better puts e.inspect puts e.backtrace result = nil error = e end if callback_id # Callback with result channel.send_message('response', callback_id, result, error) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems