LUBE (Networking Library)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: LUBE (Networking Library)

Post 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")
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LUBE (Networking Library)

Post by bartbes »

Well, you're using an old version of lube.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: LUBE (Networking Library)

Post by Davidobot »

bartbes wrote:Well, you're using an old version of lube.
Okay, thanks :awesome:
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
sam
Prole
Posts: 32
Joined: Sat Nov 10, 2012 2:18 am

Re: LUBE (Networking Library)

Post 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?
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: LUBE (Networking Library)

Post by jjmafiae »

No, as far as I know LUBE is a pure lua library (and it works here)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: LUBE (Networking Library)

Post 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]).
Help us help you: attach a .love.
zell2002
Citizen
Posts: 75
Joined: Sun Feb 23, 2014 9:22 pm

Re: LUBE (Networking Library)

Post 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 ?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LUBE (Networking Library)

Post by bartbes »

Does your server run the update method or the receive method?
zell2002
Citizen
Posts: 75
Joined: Sun Feb 23, 2014 9:22 pm

Re: LUBE (Networking Library)

Post 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
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LUBE (Networking Library)

Post by bartbes »

You're not supposed to override them, you're supposed to call them.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests