Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 3rd, 2012  |  syntax: CoffeeScript  |  size: 0.48 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class AresChannelList
  2.         constructor: ->
  3.        
  4.         send_to = new Array(
  5.                 address: "127.0.0.1"
  6.                 port: 24680
  7.         )
  8.        
  9.         sent_to = new Array()
  10.        
  11.         sock = dgram.createSocket "udp4"
  12.        
  13.         loop
  14.                 if send_to.length > 0
  15.                         send_to.forEach (obj) ->
  16.                                 try
  17.                                         buf = new Buffer(1)
  18.                                         buf[0] = 2
  19.                                         sock.send buf, 0, buf.length, obj.port, obj.address
  20.                                         sent_to.push obj
  21.                                 catch e
  22.                                         log e
  23.                                
  24.                                 send_to.pop obj
  25.                                
  26.         @socket.on "message", (buff) ->
  27.                 log "aparently got msg.."