02-28-2011, 03:18 AM
I already created something for this, and exported it to Lua
It's not documented anywhere. You basically need to 'extend' it like you extend cPlugin. You need this piece of code for that:
Then you can inherit the ReceivedData function like so:
Code:
class cTCPLink
{
public:
cTCPLink();
~cTCPLink();
bool Connect( _cstring a_Address, unsigned int a_Port );
int Send( _cstring a_Data, unsigned int a_Size, int a_Flags = 0 );
int SendMessage( const _cstring a_Message, int a_Flags = 0 );
void CloseSocket();
protected:
virtual void ReceivedData( char a_Data[256], int a_Size ) = 0;
};
It's not documented anywhere. You basically need to 'extend' it like you extend cPlugin. You need this piece of code for that:
Code:
local TCPLink = {}
TCPLink.__index = TCPLink
function TCPLink:new()
local t = {}
setmetatable(t, TCPLink)
local w = Lua__cTCPLink:new()
tolua.setpeer(w, t)
w:tolua__set_instance(w)
return w
end
Then you can inherit the ReceivedData function like so:
Code:
TCPLink:ReceivedData( Data, Size )
-- Do stuffs with data
end