Page 32 of 34

Re: LUBE (Networking Library)

Posted: Sat Dec 21, 2013 12:17 pm
by Davidobot
bartbes wrote:I don't think there is one for tcp, and there probably isn't one for enet, but for udp it's 64k.
Thanks!
Using LUBE, how would you make the server run via tcp, because (correct me if I'm wrong) by default it runs udp?

Code: Select all

server = lube.server(globalIP, globalPort)
server:setCallback(onReceive, onConnect, onDisconnect)
server:setHandshake("abc")

Re: LUBE (Networking Library)

Posted: Sat Dec 21, 2013 12:22 pm
by bartbes
Well, you're using an old version of lube.

Re: LUBE (Networking Library)

Posted: Sat Dec 21, 2013 2:54 pm
by Davidobot
bartbes wrote:Well, you're using an old version of lube.
Okay, thanks :awesome:

Re: LUBE (Networking Library)

Posted: Wed Jan 22, 2014 4:47 am
by sam
Image
just from copy/pasting the example code given, i'm given this error when i attempt to run it (good idea to right click/copy link location to see the full error). currently using 0.9.0. is it incompatible with the new version?

Re: LUBE (Networking Library)

Posted: Wed Jan 22, 2014 8:58 pm
by jjmafiae
No, as far as I know LUBE is a pure lua library (and it works here)

Re: LUBE (Networking Library)

Posted: Thu Jan 23, 2014 9:29 am
by Robin
Okay, here's the thing: LUBE uses [wiki]Class Commons[/wiki]. That allows libraries to use OOP without depending on any specific class implementation. To use it, you need a class library that is compatible with Class Commons (like Slither or [wiki]MiddleClass[/wiki]).

Re: LUBE (Networking Library)

Posted: Sun Mar 23, 2014 1:50 am
by zell2002
hi
version 0.7 i got working fine.
but version 1.0 is very different, and i just can't get it to work at all

globals :

Code: Select all

_ip = "127.0.0.1"
_port = "18025"
server code :

Code: Select all

function StartServer()
    server = lube.udpServer()
    server:listen(_port)
    server.callbacks.connect = onConnect
    server.callbacks.recv = onReceive
    server.handshake = "Hi!"
    print("created")
end
client code :

Code: Select all

function StartClient()
    client = lube.udpClient()
    client.handshake = "Hi!"
    client.callbacks.recv = Receive
    success, er = client:connect(_ip, _port)
    print("success : " .. tostring(success)) 
    return success
end
regardless if the server is running StartClient() is always successful - I assume this is due to the nature of udp being connectionless ? (maybe?). Or should it only connect to a port that is being "listened" on ? If this is so.. then I have no idea why/how it always connects successfully.

the main problem is, in the server code i have

Code: Select all

function onConnect(id)
    print("Connected : " .. id)
    server:send("hi")
end
"Connected : ip:port" gets printed to my log so that's all good.
but server:send("hi") is NEVER received by the client

inside LUBE.lua, it fails here

Code: Select all

function udpClient:_receive()
	local data, ip, port = self.socket:receivefrom()
	print(data)
	if ip == self.host and port == self.port then
            return data
	end

        print("data " .. tostring(data))
        print("ip " .. ip)
        print("port " .. tostring(port))
        print("self host : "..self.host)
        print("self port : "..self.port)

	return false, "Unknown remote sent data."
end
console window:
nil
data nil
ip timeout
port nil
self host : 127.0.0.1
self port : 18025
What am I missing here ?

Re: LUBE (Networking Library)

Posted: Sun Mar 23, 2014 9:56 am
by bartbes
Does your server run the update method or the receive method?

Re: LUBE (Networking Library)

Posted: Sun Mar 23, 2014 10:33 am
by zell2002
yea
in LUBE :

Code: Select all

function server:update(dt)
print("server update")
-- more code
end

function udpServer:receive()
print("server rec!")
local data, ip, port = self.socket:receivefrom()	
print("data : " .. tostring(data))
-- more code
end
both these functions run
data is always nil

Re: LUBE (Networking Library)

Posted: Sun Mar 23, 2014 10:57 am
by bartbes
You're not supposed to override them, you're supposed to call them.