Page 19 of 34

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Tue Dec 29, 2009 10:46 pm
by stampede
This is getting more confusing now. Hmm. Why can't I just

Code: Select all

tcp_server = lube.server
tcp_server:Init(1234, "tcp") -- Yeah it's probably "tcp", I just messed up it
Would be great to wrap my head around this so when you update the clients table thing, I could use it straight away :S

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Tue Dec 29, 2009 10:49 pm
by bartbes
Because it would point to the same table, that's how lua works.
Just run

Code: Select all

tcp_server = lube.server(1234, "tcp")
and you should be fine. However I might add a check to see if there's an argument passed to lube.server, so in the next version you might be able to do

Code: Select all

tcp_server = lube.server()
tcp_server:Init(1234, "tcp")
if that helps you.

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Tue Dec 29, 2009 10:54 pm
by stampede
Ah yeah now I got it, at least partially. So are you going to add lube.server function to the new version, or do I write it myself?

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Tue Dec 29, 2009 10:59 pm
by bartbes
It is already in the current version.

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Tue Dec 29, 2009 11:04 pm
by stampede
Hmm, not good enough in lua yet, didn't find it in the lube.lua :( But alrighty mighty! So I can just init two tables (one for tcp and other for udp data exchanging) with lube.server() and it should work right once you update the clients table thing?

Thanks for helping with this! And hope this project helps to improve Lube and find bugs in it :D Going to come and ask bunch of questions some day again probably!

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Tue Dec 29, 2009 11:05 pm
by bartbes
Well, this keeps me 'interested', that's a good thing. And it's certainly something else than fixing debs (what I've done the last 3 days)

EDIT: Oh, btw, there is no function called lube.server for the simple reason that I did use that fairy magic, and my spell was called metatables :P

EDIT2: Which basically means the function is there, it just doesn't have that name, complicated, but you can act like there is one.

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Tue Dec 29, 2009 11:16 pm
by stampede
Yeah, thought after couple of your posts that it must be that one. I just don't understand all the metatables and other hassle in lua yet :P

Currently writing a basic online rpg engine. Been wanting to write one for years, and finally I think I can really do it with Löve+Lube. Basic idea of this rpg (after I have all the basic networking things) is getting away from all that level grinding shit and making it all about hunting treasures and new places with your friends. It's more like basic 2d Zelda game, as in example: you go to a dungeon and realise after a while, that you can't open that particular door without a friend pushing the other button. After you've completed the dungeon, you get the hidden treasure, like hookshot. That makes you able to reach to new interesting places to explore with more dungeons and treasures.

Have been brainstorming about this for couple of weeks now. Have to start writing something down soon. But wanted to try to create basic networking at the same time :P

EDIT: oh had to ask about this some time ago already, but can handshake be used as a client version checking? Like update server's and client's handshake variable always with the new version of the client, and then just send something as an OK from the server with connect callback function so client can continue to the login screen? Or something along that.

EDIT2: is there some convenient way to make server check the data it receives, if it's really from the client or if it's just some other data from same ip? I think it just crashes the server if I first try to unpack the data and then check the first value if it's anything server can read. Hmm... Have to think about this a bit.

EDIT3: is there a way to make TCP asynchronous? So it wouldn't wait for the messages to come.

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Wed Dec 30, 2009 10:40 am
by bartbes
Sounds like a fun game.
I don't think the handshake is intelligent enough (but then again, I forgot), but this is easily implemented yourself.
And it blocks all data from unconnected clients by itself, so that'll help you in your quest. (well, it will once I fix the clients, but ease up on me, I just woke up)
And I thought I made everything asynchronous, no, I know everything is asynchronously handled. Well, internally at least, but I think the others are asynchronous too.
I'll post back after fixing LUBE, oh and btw, I'll finally upload the manual I have had for a while now (updated)

EDIT: Oh, what you could do, is set the handshake to the version number, and send an ok message back in the connect callback, if the client receives that he knows he has connected.

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Wed Dec 30, 2009 10:50 am
by stampede
bartbes wrote:EDIT: Oh, what you could do, is set the handshake to the version number, and send an ok message back in the connect callback, if the client receives that he knows he has connected.
That's exactly what I'm doing now! Been up all night long coding this system :D

Tested first with the tcp, and the server side seemed to hang somewhere in the middle of login process... I'll try again today probably. Maybe I just had some bug in my code...

EDIT: about the packet checking, wouldn't the server crash if
1. login with the normal client
2. send a random packet with different program to the server with same port as real client
3. server tries to unpack this random packet, but because it's not a proper pack, it crashes
Right?

Re: LUBE (Networking Library) v0.6.1 + LUBE-X v0.02

Posted: Wed Dec 30, 2009 12:36 pm
by bartbes
It'd only crash if the packet was strangely formed, otherwise the pattern would just fail and you would get an empty result. Anyway, I think I'm nearly done, I wonder if you could test my work?