LUBE (Networking Library)

Showcase your libraries, tools and other projects that help your fellow love users.
Bambo
Prole
Posts: 41
Joined: Thu Mar 24, 2011 8:23 pm
Location: Warrington, England
Contact:

Re: LUBE (Networking Library)

Post by Bambo »

Hey, i got it kinda working! Not sure if its right though...

the one bug i'm having trouble with is that when a user leaves the server, if there is another person connected when they try to move it gives an error on line 64 serverside. other than that its pretty cool...
Attachments
networking.zip
(17.93 KiB) Downloaded 205 times
User avatar
tsturzl
Party member
Posts: 161
Joined: Fri Apr 08, 2011 3:24 am

Re: LUBE (Networking Library)

Post by tsturzl »

LUBE offers UDP but only server-client style connecting. UDP is connectionless... Why can I not create 2 clients that send udp to eachother, or can I? If so, how do I do this? Have all the hosts that are connected in use a server object? So server to server?
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 »

The way LUBE is set up is it assumes that one of the two is 'in charge', i.e. it being the server, there is nothing preventing you from running multiple servers and/or clients though. If you're not looking for this, you should consider using luasocket directly.
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 »

A new version in testing. Not just a new version, a complete rewrite.
Anyway, no real new features, except for the fact it now uses proper classes, courtesy of Class Commons.

(To those uninitiated, this means that it can be used with all participating class libraries, which, at the moment of writing, are SECS, Slither and HUMP. (And MiddleClass?))

Find the new version here: https://github.com/bartbes/love-misc-li ... E/LUBE.lua.
BURGINABC
Prole
Posts: 2
Joined: Tue Oct 25, 2011 7:40 pm

Re: LUBE (Networking Library)

Post by BURGINABC »

How do you do pack nested tables with lube.bin:pack? I know it has something to do with lube.bin:setseperators, but the documentation wasn't exactly clear on how you go about it. I spent some time trying to figure out a solution on my own, even printed a packed-table string to console to look at the structure, but I haven't gotten anything to work. Please help, and if there is a solution you should probably make the documentation in the wiki or included html files more detailed/specific, so people don't have to ask you. What there is now, in terms of documentation, just isn't enough for a novice like me to figure out.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: LUBE (Networking Library)

Post by TechnoCat »

BURGINABC wrote:How do you do pack nested tables with lube.bin:pack?
There are a couple options for table serialization:
http://love2d.org/wiki/TLTools
http://love2d.org/wiki/Serial
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, the idea is that you start at the furthest embedded table, pack it, set the separators to new values, go up in the tree a step (so to the table that contains that/those), pack, and repeat the process until you've reached the end.

This is not very user-friendly, and lube.bin hasn't made the rewrite either. For your convenience, and mine, probably, you should really look at other serialization options. I've heard the name TSerial mentioned quite a bit, here is its wiki page.

Ninja'd, I tip my hat to the, TechnoCat.
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 »

Note that not all implementations of table serialisation can detect cycles, and can get into an infinite loop if you pass a table like:

Code: Select all

t = {}
t[1] = t
Help us help you: attach a .love.
BURGINABC
Prole
Posts: 2
Joined: Tue Oct 25, 2011 7:40 pm

Re: LUBE (Networking Library)

Post by BURGINABC »

thanks TechnoCat, "serial" actually works! It creates a function for reconstructing the table and crams it inside a string. the recipient's end declares the function by loadstring-ing the string, then calls the function to reconstruct the table. It may be a tad inefficient, but it certainly works better, for me at least, than the data format used by lube.bin:pack, because it doesn't break when you feed it nested tables. Well, problem solved. :awesome:

As for TSerial, it didn't work for me. It kept calling my indexes invalid.
User avatar
zipperipper
Prole
Posts: 45
Joined: Thu Jan 14, 2010 7:59 pm
Location: UK

Re: LUBE (Networking Library)

Post by zipperipper »

Any reason when a player disconnects that it sets the index of a player to 0?
it seems to screw up the whole list of clients, which is making it difficult to work with disconnections :I
edit:
In my server, if client 2 disconnects, it leaves me with clients 1 and 3, as it should, but then client 3 times out
Image
It prints the client list every time, you see I am eventually left with just client 1
Error 404, consciousness not found.
Post Reply

Who is online

Users browsing this forum: No registered users and 183 guests