Last active
June 23, 2017 08:05
-
-
Save moteus/e9b667912b274df2046f875a853c5f6b to your computer and use it in GitHub Desktop.
Wrapper class to use lluv socket class with pgmoon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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