Sha256: 9917157a9b1432f3af1d45c72718fc11deb922a64a72a8a5283d5c0d0f0b3002

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

$:.unshift File.dirname(__FILE__)+"/../../lib/"
require 'magent'

# Use: magent /path/to/this/file

Magent.push("/bot", :echo, "hello, world")
Magent.push("/bot", :do_task, "File", :exist?, "/etc/passwd")
Magent.push("/bot", :echo, "Press ctrl+c to close")

class Bot
  include Magent::Actor

  expose :echo, :do_task

  def echo(payload)
    $stderr.puts payload.inspect
  end

  def do_task(payload)
    klass, *args = payload

    result = Object.module_eval(klass).send(*args)
    $stderr.puts "RESULT: #{result}"
  end

end

Magent.register(Bot.new)

if $0 == __FILE__
  Magent::Processor.new(Magent.current_actor).run!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magent-0.0.1 examples/simple/bot.rb