module TextProtocols

Constants

VERSION

Public Class Methods

log(string) click to toggle source
# File lib/text_protocols.rb, line 28
def self.log string
  puts string
  $stdout.flush
end
set_signals_hooks() click to toggle source
# File lib/text_protocols.rb, line 11
def self.set_signals_hooks
  ['SIGINT', 'SIGTERM'].each do |signal|
    Signal.trap signal do
      log "Bye!"
      exit
    end
  end
end
start(port='5000', bind='127.0.0.1', &block) click to toggle source
# File lib/text_protocols.rb, line 6
def self.start port='5000', bind='127.0.0.1', &block
  set_signals_hooks
  start_server port, bind, block
end
start_server(port, bind, block) click to toggle source
# File lib/text_protocols.rb, line 20
def self.start_server port, bind, block
  server = Server.config port, bind, &block
  server.start
  sleep
rescue Interrupt
  log "Server was interrupted..."
end