Module: EventMachine::Wssh::Client

Defined in:
lib/em/wssh/client.rb

Defined Under Namespace

Modules: Stdio Classes: Ws

Constant Summary collapse

Title =
'Connect to WSSH server'
Need =
%w(faye/websocket)

Class Method Summary collapse

Class Method Details

.getoptObject



20
21
22
23
# File 'lib/em/wssh/client.rb', line 20

def self.getopt
  help if ARGV.length!=1
  @uri=ARGV[0]
end

.go!Object



93
94
95
96
97
# File 'lib/em/wssh/client.rb', line 93

def self.go!
  getopt
  STDOUT.sync=true
  loop!
end

.helpObject



10
11
12
13
14
15
16
17
18
# File 'lib/em/wssh/client.rb', line 10

def self.help
  require_relative 'exe'
  puts <<-EOT
WSSH client

#{Exe.usage} ws[s]://host[:port]/uri
  EOT
  exit 1
end

.listen!Object



84
85
86
# File 'lib/em/wssh/client.rb', line 84

def self.listen!
  EM.attach $stdin, Stdio, Ws.new(@uri)
end

.loop!Object



88
89
90
91
# File 'lib/em/wssh/client.rb', line 88

def self.loop!
  self::Need.each{|f| require f}
  EM.run{ listen! }
end