local fs = require('fs') local ZD = require("./../init.lua")() local simpleHTTP = ZD.simpleHTTP(80, function(req, out) out([[ ]], "text/html") end) simpleHTTP:addDataType("html", "text/html") simpleHTTP:addDataType("js", "text/javascript") local luaCache = {} simpleHTTP:addDataType("lua", function(url, cb) if fs.existsSync("." .. url.path) then luaCache[url.path] = luaCache[url.path] or require("." .. url.path) or {} if luaCache[url.path].onRequest then luaCache[url.path].onRequest(url, cb) end else cb() end end) local socket = ZD.ZedSocket(1734, false) -- AJAX Server will be running on this port, Websocket Server on this port + 1, setting the second arguments to true will only use Websocket on the give port socket:onConnection(function(client) print("Client connected.") client:on("Foo", function(data) print(data.msg) client:send("Foo", data) end) client:on("disconnect", function(data) print("Client disconnected.") end) end)