Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Can now tail log and stuff w/ talker-cat

  • Loading branch information...
commit 14c56861e5134280c8d6f914d6b0604137326606 1 parent c29c3c2
Marc-André Cournoyer authored December 14, 2009

Showing 1 changed file with 19 additions and 2 deletions. Show diff stats Hide diff stats

  1. 21  bin/talker-cat
21  bin/talker-cat
@@ -21,12 +21,29 @@ usage: echo 'something' | talker-cat <room_id>
21 21
   
22 22
 EOS
23 23
 
  24
+# Non-blocking reader for stdin
  25
+module Reader
  26
+  attr_accessor :client
  27
+  
  28
+  def notify_readable
  29
+    @client.send_message @io.readline.chomp
  30
+  rescue EOFError
  31
+    detach
  32
+  end
  33
+  
  34
+  def unbind
  35
+    @client.close
  36
+  end
  37
+end
  38
+
24 39
 Talker.connect(:room => room.to_i, :token => token) do |client|
25 40
   client.on_connected do
26  
-    client.send_message STDIN.read
27  
-    client.close
  41
+    conn = EM.watch STDIN, Reader
  42
+    conn.client = client
  43
+    conn.notify_readable = true
28 44
   end
29 45
   client.on_error do |error|
30 46
     puts error
31 47
   end
  48
+  trap("INT") { client.close }
32 49
 end

0 notes on commit 14c5686

Please sign in to comment.
Something went wrong with that request. Please try again.