Sha256: c0334978b90c1e7357d46f8361cde599b7ed8d113ca9cb4e7e99d40857c5b03b

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

-- I don't know where the proper place for this file is. It's not really a helper
waxClass{"WaxServer"}

-- Class Method
---------------
function start(self)
  self.server = wax.class['wax_server']:init()

  local err = self.server and self.server:startOnPort(9000)
  if err then
    puts("Failed creating server: %s", err and err:description() or "Server Not Created")
    return err
  end

  self.server:setDelegate(self)

  -- redirect print
  local formerPrint = print
  _G.print = function(...)
    formerPrint(...) 
    local objects = table.map({...}, function(o) return tostring(o) end)
    self.server:send(table.concat(objects, '\t') .. "\n")
  end

  return nil
end

function showPrompt(self)
  self.server:send "> "
end

-- DebugServerDelegate
----------------------
function connected(self)
  self:showPrompt()
end

function disconnected(self)
  self.server:send("GOODBYE!")
end

function dataReceived(self, data)
  local input = NSString:initWithData_encoding(data, NSASCIIStringEncoding)
  local success, err = wax.eval(input)

  if not success then self.server:send("Error: " .. err .. "\n") end

  self:showPrompt()
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
candle-0.0.7 lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua
candle-0.0.6 lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua
candle-0.0.4 lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua
candle-0.0.3 lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua
candle-0.0.2 lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua
candle-0.0.1 lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua