Skip to content

Instantly share code, notes, and snippets.

@moteus moteus/pgmoon.lluv.lua
Last active Jun 23, 2017

Embed
What would you like to do?
Wrapper class to use lluv socket class with pgmoon
-- socket = require "pgmoon.lluv".Socket.new()
local ut = require "lluv.utils"
local socket = require "lluv.luasocket"
local flatten = require("pgmoon.util").flatten
local function Super(class)
return function(self, m, ...)
if class.__base and class.__base[m] then
return class.__base[m](self, ...)
end
if m == '__init' then
return self
end
end
end
local Socket = ut.class(socket._TcpSocket) do
local super = Super(Socket)
function Socket:settimeout(v)
if v then v = v / 1000 end
return super(self, 'settimeout', v)
end
function Socket:getreusedtimes()
return 0
end
function Socket:send(data, ...)
return super(self, 'send', flatten(data), ...)
end
end
return {
Socket = Socket;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.