Page 30 of 34

Re: LUBE (Networking Library)

Posted: Mon May 28, 2012 2:00 pm
by schme16
bartbes wrote:You could take a look at this function here: https://github.com/Nevon/cardboard/blob ... n.lua#L181. That code uses hump.class, btw, so you might have to change the class instantiation syntax.

Thanks for the link! I noticed that I was missing the handshake when attempting to connect, this is apparently a var that must be set when connecting via tcp (I had no idea :shock:)

Re: LUBE (Networking Library)

Posted: Sat Nov 10, 2012 3:32 am
by Cowinatub
Is packing still supported in the newest release?
Whenever I try and use it it just says 'Attempted to index bin(nil value)'.

Re: LUBE (Networking Library)

Posted: Mon Dec 10, 2012 7:18 pm
by qaisjp
Can you do multiple connections for one server/client (I'd like to use TCP for message/score sharing and UDP for realtime sync)?
Or should I just use multiple servers and clients for each socket type?

Re: LUBE (Networking Library)

Posted: Sat Jan 19, 2013 4:50 am
by Lemony Lime
Are there any real tutorials on how to get started with LUBE? I've found a reasonable amount of info and examples, but no real tutorials, which are always much easier to learn from. Would anyone be willing to write (or link me to, if one already exists) a simple getting started guide, for the betterment of humanity? I'm sure I'll find my way on my own eventually, but if I can avoid the extra work, I'd like to... what with college and work and all that.

Re: LUBE (Networking Library)

Posted: Sat Jan 19, 2013 9:32 am
by bartbes
Well, the OP points to viewtopic.php?f=5&t=230&start=210#p21112, and even though some tutorials might be old, this only means the syntax doesn't apply, the way of doing things is still mostly the same.
I've also been asked for a simple-ish example with a modern version, and then I usually link to: https://github.com/Nevon/cardboard/blob ... n.lua#L181

Re: LUBE (Networking Library)

Posted: Sun Feb 24, 2013 2:59 pm
by Frohman
I'm having trouble trying to get set up with LUBE :c, I'm using the current development version and hump.class.

Code: Select all

local Vector = require "hump.vector"
local Class = require "hump.class"
require "LUBE" -- for the intertubes[
require "player"
After that I'm trying to set up a ucpClient for use, but for the life of me I can't figure out how to do this correctly, even after seeing an apparently correct implementation at https://github.com/Nevon/cardboard/blob ... n.lua#L181

Here's what two methods I've tried:

Code: Select all

local client

function love.load()
	love.graphics.setBackgroundColor(33, 89, 125)

	cfg = love.filesystem.read("userconfig.cfg")
	ip, port = cfg:match("^(.+):(%d+)$")
	assert(ip and port)

	client = lube.udpClient()
	client.callbacks.recv = onReceive
	p:load()
end
attempt to call field 'udpClient' (a nil value)

Code: Select all

local client = Class{}

function love.load()
	love.graphics.setBackgroundColor(33, 89, 125)

	cfg = love.filesystem.read("userconfig.cfg")
	ip, port = cfg:match("^(.+):(%d+)$")
	assert(ip and port)

	client:include(lube.udpClient)
	client:init()
	client.callbacks.recv = onReceive
	p:load()
end
attempt to index field 'callbacks' (a nil value)

I'm very new to networking and classes, so I'm sure I'm at fault here - if someone could tell me how, it'd be greatly appreciated!

Re: LUBE (Networking Library)

Posted: Sun Feb 24, 2013 3:13 pm
by bartbes
This looks like it should work (the first method, anyway), are you sure the require statements are in the right place?

Re: LUBE (Networking Library)

Posted: Sun Feb 24, 2013 3:18 pm
by Frohman
I think so?
Here's the entire main.lua:

Code: Select all

local Vector = require "hump.vector"
local Class = require "hump.class"
require "LUBE" -- for the intertubes
require "player"


universe = {}
p = LocalPlayer(Vector(200, 200))

local client

function love.load()
	love.graphics.setBackgroundColor(33, 89, 125)

	cfg = love.filesystem.read("userconfig.cfg")
	ip, port = cfg:match("^(.+):(%d+)$")
	assert(ip and port)

	client = lube.udpClient()
	client.callbacks.recv = onReceive
	p:load()
end

function love.update(dt)
	p:update(dt)
	p:integrate(dt)
end

function love.draw()
	p:draw()
end

function onReceive(data)
	print(data)
end
Here's another approach, this time not bothering with LOVE at all:

Code: Select all

local Class = require "hump.class"
require "LUBE"

for k,v in pairs(lube) do
	print(k,v)
end
Same result - nothing is printed and the program runs successfully. Lube somehow exists but doesn't have any of its uh, fields...

I'll ask in the support subforums

Re: LUBE (Networking Library)

Posted: Sun Jul 21, 2013 1:18 pm
by bartbes
I've updated the repository, so LUBE is now a directory, instead of a single monolithic file, and it now also ships with a fallback class commons implementation (I still encourage you to use your own, though). Furthermore, I've added a conditional enet backend, to prepare for 0.9.0, I figured some of you might be interested in that too. Of course, since it's restricted to the LUBE api, it's less powerful than using it directly, but it does mean users can now easily switch, and it's still the same, simple api.

Re: LUBE (Networking Library)

Posted: Fri Oct 04, 2013 2:18 pm
by ArchAngel075
Im not exactly sure how to set callbacks, i first tried defining them like :

Code: Select all

function server.callbacks.connect(clientid)
--
end
but i error with attempt to index 'server' (nil value)

next i tried :

Code: Select all

function onConnect(clientid)
 print("Client Connected")
end

function love.load()
 -- create the server etc
 server.callbacks.connect = onConnect
end
but this seems to not work as when my client connects i have no message.
Also i have made sure if the server and clients work, i can have a client send a message and then do server:receive() with success.
I also used print(not not server.callbacks) to check if the callbacks table exists and the function is assigned.

-end-