6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/nirvana/websocket.rb', line 6
def self.run
EventMachine.run do
EventMachine::WebSocket.start(:host => '127.0.0.1', :port => 8080) do |ws|
ws.onopen {
result = Nirvana::Runner.run ARGV
ws.send(result) unless result.to_s.empty?
}
ws.onmessage {|msg| ws.send Ripl.shell.web_loop_once(msg) }
ws.onclose { Ripl.shell.after_loop }
end
end
rescue
message = "Unable to start websocket since port 8080 is occupied"
message = $!.message unless $!.message[/no acceptor/]
abort "nirvana websocket error: #{message}"
end
|