Sha256: d9fe9b933d92d59cd18797a55dc77fc5ceabcd54d2860a11bdee7856724f58d0

Contents?: true

Size: 620 Bytes

Versions: 3

Compression:

Stored size: 620 Bytes

Contents

require 'tork/client'

module Tork
module Server

  def quit
    Thread.exit # kill Client::Receiver in loop()
  end

  def loop
    @client = Client::Transmitter.new(STDOUT.dup)
    STDOUT.reopen(STDERR).sync = true

    Client::Receiver.new(STDIN) do |command|
      method = command.first
      if respond_to? method and method != __method__ # prevent loops
        @command = command
        __send__(*command)
      else
        warn "#{self}: invalid command: #{method}"
      end
    end.join
  rescue Interrupt
    # forced quit
  end

  def self.extended server
    trap(:SIGTERM){ server.quit }
  end

end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tork-17.1.0 lib/tork/server.rb
tork-17.0.1 lib/tork/server.rb
tork-17.0.0 lib/tork/server.rb