LUBE (Networking Library)

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

LUBE (Networking Library)

Post by bartbes »

Here's my networking library named LUBE, this post is now used for project status.

Current version: 1.0
Version 1.0 (press 'raw' for download, or check out the repo and use the 'LUBE-1.0' tag)
Version 1.0 docs

Development version
Development version docs

Old releases:
LUBE.zip
0.7.1
053010
(14.3 KiB) Downloaded 3086 times
LUBE.zip
0.7.0
011510
(14.27 KiB) Downloaded 1998 times
Lag-o-meter 3000 -> page 12
TechnoCat's awesome introductory writeup
Last edited by bartbes on Tue Jul 21, 2009 10:04 am, edited 55 times in total.
User avatar
TsT
Party member
Posts: 161
Joined: Thu Sep 25, 2008 7:04 pm
Location: France
Contact:

Re: Networking Library

Post by TsT »

bartbes wrote:Any suggestions for a name?
Maybe UdpClient ?
My projects current projects : dragoon-framework (includes lua-newmodule, lua-provide, lovemodular, , classcommons2, and more ...)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Networking Library

Post by bartbes »

Thanks! I'll look at other suggestions (if any) before going with this name though.
Last edited by bartbes on Thu Oct 23, 2008 1:51 pm, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Networking Library

Post by bartbes »

Moved changelog to first post, added host.
u9_
Citizen
Posts: 54
Joined: Thu Oct 23, 2008 7:12 am

Re: Networking Library

Post by u9_ »

Hi, i'm new here, so not really sure if this is applicable what i'm saying, if you are making a network library for LOVE, you should stick to LOVEs naming convention, i.e. function names start with lower case letters.

Personally i prefer starting with a capital letter, but I think maintaining a standard is much better then everyone going in his own direction.

/u9
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Networking Library

Post by bartbes »

You're right :D

Added to list.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Networking Library

Post by bartbes »

Suggestion for binary packing:

Code: Select all

1 byte identifier (S=string, N=number, etc)
byte with value 1
name
byte with value 1
value
byte with value 0
this is basically

Code: Select all

id-1-name-1-value-0
So? Do you agree? Or do you have other ideas about packing? Post!
User avatar
TsT
Party member
Posts: 161
Joined: Thu Sep 25, 2008 7:04 pm
Location: France
Contact:

Re: Networking Library

Post by TsT »

Let's see my new network tcp client lib version.
Sample of code

Code: Select all


function j2h_parseline(line)
   
[...]

   if cmd == "ping" then
      log("receive ping sending pong...n-i-y");
      network:execCmd("pong", line);
      return 0;
   end
   if cmd == "pong" then
      local lag = os.difftime (os.time(), line);
      log("pong reply(" .. tostring(line) .. ") lag = " .. tostring(lag) .. " s");
      return 0;
   end

[...]

   return 1;
end

function j2h_db_update(datafound)
   if datafound then
      log("data found ... here you can show number of updated lines ..."
   --else
   --   you can also do something here, when data found but nothing require update
   end
end

function load()
   love.filesystem.require( "network.lua" );
   config.host = "myhost.domain.com";
   config.port = 1234;

   socket = require("socket");
   network = Network:New("tcp-client");
   network:setLogHandler(
      function(...)
         print("network: " .. ...);
      end
   );
   network:Setup(config.host, config.port);
   network:setParseHandler(j2h_parseline); -- execute for each line received
   network:setEndHandler(j2h_db_update); -- execute after parse all line

   network:addCmd("getall",
      function(self)
         local lines = "GET *";
         self:Send(lines);
         j2h_log("send getall request");
      end
   );

   network:addCmd("ping",
      function(nw)
         local time = os.time();
         local lines = "ping " .. tostring(time) .. "\n"
         nw:Send(lines);
         j2h_log("ping " .. tostring(time));
      end
   );
   network:addCmd("pong",
      function(nw, data)
         nw:Send("pong", data);
      end
   );

   network:Setup(config.host, config.port);
   network:Enable()
   network:execCmd("getall");
end

function j2h_quit()
   network:Disable();
   love.system.exit();
end


function update(dt)
   network:Update(dt);
end

network.lua
j2h network lib v0.1.2 (r266)
(4.56 KiB) Downloaded 1792 times
My projects current projects : dragoon-framework (includes lua-newmodule, lua-provide, lovemodular, , classcommons2, and more ...)
funcoot
Prole
Posts: 1
Joined: Mon Oct 27, 2008 1:17 am

Re: Networking Library

Post by funcoot »

Hey, I had an idea for a name, but it is generic. "LÖVE CÖNNECTION"

Anyways I also a had another proposition. If you can actually get this project off the ground with a working example in a game, I would be happy to contribute a web site. If I had the free time. I do web design.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Networking Library

Post by bartbes »

Yeah, this topic actually started at http://love2d.org/forum/viewtopic.php?f=3&t=225, I was talking about a game there too.
And as I said there, I'm not going to code an entire game myself (as I just plain suck at graphics), however I would help as much as possible when (NOT IF!) someone starts a project.
And this will actually help this lib <insert name here>, because the best way to create a library is by actually using it.
So.. volunteers?

@funcoot: noted the name suggestion, I'll wait for a little longer and start a poll
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests