lib/include/class_knjappserver_cmdline.rb in knjappserver-0.0.23 vs lib/include/class_knjappserver_cmdline.rb in knjappserver-0.0.24
- old
+ new
@@ -2,30 +2,29 @@
def initialize_cmdline
@cmds = {}
Thread.new do
begin
- line = $stdin.gets
- next if line == "\n"
-
- called = 0
- @cmds.each do |key, connects|
- data = {}
-
- if key.is_a?(Regexp)
- if line.match(key)
- connects.each do |conn|
- called += 1
- conn[:block].call(data)
+ $stdin.each_line do |line|
+ called = 0
+ @cmds.each do |key, connects|
+ data = {}
+
+ if key.is_a?(Regexp)
+ if line.match(key)
+ connects.each do |conn|
+ called += 1
+ conn[:block].call(data)
+ end
end
+ else
+ raise "Unknown class for 'cmd_connect': '#{key.class.name}'."
end
- else
- raise "Unknown class for 'cmd_connect': '#{key.class.name}'."
end
- end
-
- if called == 0
- print "Unknown command: '#{line.strip}'.\n"
+
+ if called == 0
+ print "Unknown command: '#{line.strip}'.\n"
+ end
end
rescue => e
self.handle_error(e)
end
end
\ No newline at end of file