Just have to say that I love this library. I've used it multiple times for online multiplayer games and has been easy to work with. I can't recommend it enough for people who want to start playing around with networking.
My only real feedback would be:
- I think logging all events is a bit much. Typically I changed it to just log errors and warnings because otherwise in usage it can bloat memory usage. I'm guessing the current implementation is just a stop-gap until it writes logs once they reach a certain length, but it feels a bit like a "gotcha" right now.
- Might be helpful to people unfamiliar how to include a short blurb of how to set up a dedicated server. (i.e get LuaJIT, install/make enet and other dependencies, etc) But I understand that's a topic that can easily grow to be quite lengthy and in depth, and could just be out of your intended scope.
sock.lua - A simple networking library for LÖVE
Re: sock.lua - A simple networking library for LÖVE
I agree, the logging functionality is sorely lacking at the moment. I'd like to keep some logging ability, but I don't want to use up lots of memory or silently create huge log files. One option would be to keep logging completely minimal by default (print to stdout only) and then have the option of redirecting to a log file if needed. I would accept pull requests to expand and improve the logging.CherryBit wrote: - I think logging all events is a bit much. Typically I changed it to just log errors and warnings because otherwise in usage it can bloat memory usage. I'm guessing the current implementation is just a stop-gap until it writes logs once they reach a certain length, but it feels a bit like a "gotcha" right now.
I would expect most people to just do ad-hoc networking, but I think this information would be useful to put somewhere. As you said, it probably lies outside the scope of this library though. Installing LuaJIT and enet to run a dedicated LOVE server is more of a general LOVE/Lua topic than it is a sock.lua topic.CherryBit wrote: - Might be helpful to people unfamiliar how to include a short blurb of how to set up a dedicated server. (i.e get LuaJIT, install/make enet and other dependencies, etc) But I understand that's a topic that can easily grow to be quite lengthy and in depth, and could just be out of your intended scope.
Re: sock.lua - A simple networking library for LÖVE
Hello!
I was thinking of creating a rooms table server-side to store client sockets in each room. Then whenever I want to send a message to a specific room I'd just iterate over the rooms[id] table and send a message to each socket.
Or, I'd simply use :setSendChannel(roomId). Is that its purpose?
Thanks!
I'm making a turn-based game and I'd like to set up an authoritative server-client architecture. I need multiple rooms and matchmaking.Ikroth wrote:sock.lua
I was thinking of creating a rooms table server-side to store client sockets in each room. Then whenever I want to send a message to a specific room I'd just iterate over the rooms[id] table and send a message to each socket.
Or, I'd simply use :setSendChannel(roomId). Is that its purpose?
Thanks!
Re: sock.lua - A simple networking library for LÖVE
Channels send data concurrently over the network, you can use that functionality in any way you would like. If you send a reliable message and it is not received on the other end, that can cause delay on that channel, because it has to resend the packet. Packets on other channels are not affected by this. Common things to send separately might be physics, chat, and files. Things unimportant to the actual gameplay should not affect network latency.Ulydev wrote:Hello!
I'm making a turn-based game and I'd like to set up an authoritative server-client architecture. I need multiple rooms and matchmaking.Ikroth wrote:sock.lua
I was thinking of creating a rooms table server-side to store client sockets in each room. Then whenever I want to send a message to a specific room I'd just iterate over the rooms[id] table and send a message to each socket.
Or, I'd simply use :setSendChannel(roomId). Is that its purpose?
Thanks!
I would suggest that you keep the number of channels small, because I don't think channels were intended to scale up to hundreds, but it's possible.
Re: sock.lua - A simple networking library for LÖVE
Thanks for your answer! I need a few hundred channels in my case (or game rooms, more specifically), so I guess I'll implement my own :broadcastToGameRoom() methodIkroth wrote:-
Re: sock.lua - A simple networking library for LÖVE
Hello there, I'm trying to send some data on client connect (e.g. client version, client name), but whatever I put in client:connect(), the server doesn't get the data.Ikroth wrote:sock.lua
Code: Select all
--client
client:connect()
--server
server:on("connect", function( data, client )
print(data) --always displays "0"
end)
- Sir_Silver
- Party member
- Posts: 286
- Joined: Mon Aug 22, 2016 2:25 pm
- Contact:
Re: sock.lua - A simple networking library for LÖVE
My roundabout solution for this would be to use another event that you send when the client connects to the server, like such:
So when the client connects to the server, it will then send a message to the server with the clients version, (and whatever else you may want to send) and do stuff with that.
Code: Select all
client:on("connect", function(data)
client:send("version", {love.getVersion()}) --love.getVersion returns multiple args, so we have to store them in a table and then send it.
end)
server:on("version", function(version, client)
--Do stuff with the client's version, like kick them if they don't have the right one.
end)
- emanevitaerc
- Prole
- Posts: 17
- Joined: Sun Mar 13, 2016 7:21 am
Re: sock.lua - A simple networking library for LÖVE
Just, wow. I'll absolutely be following this as development goes along. Definitely going to use this, great work.
Re: sock.lua - A simple networking library for LÖVE
Ulydev wrote: ↑Tue Mar 14, 2017 5:25 pmHello there, I'm trying to send some data on client connect (e.g. client version, client name), but whatever I put in client:connect(), the server doesn't get the data.Ikroth wrote:sock.lua
How should I do it?Code: Select all
--client client:connect() --server server:on("connect", function( data, client ) print(data) --always displays "0" end)
This would be the way to do it for right now. The :connect() function is supposed to allow you to send an integer, but it would be nice if it at least let you send a table.Sir_Silver wrote: ↑Tue Mar 14, 2017 5:48 pm My roundabout solution for this would be to use another event that you send when the client connects to the server, like such:
So when the client connects to the server, it will then send a message to the server with the clients version, (and whatever else you may want to send) and do stuff with that.Code: Select all
client:on("connect", function(data) client:send("version", {love.getVersion()}) --love.getVersion returns multiple args, so we have to store them in a table and then send it. end) server:on("version", function(version, client) --Do stuff with the client's version, like kick them if they don't have the right one. end)
Also, I'm going to work on some updates soon. There's some enet functions that I haven't implemented yet, somehow. And if anyone here knows about adding networking to Travis CI, send me a message.
Re: sock.lua - A simple networking library for LÖVE
Apologies for the double post, but I have released version 0.3.0 of sock.lua!
https://github.com/camchenry/sock.lua/r ... /tag/0.3.0
A brief changelog of some of the changes:
You can check out the repository here: https://github.com/camchenry/sock.lua and the documentation here: http://camchenry.com/sock.lua/
https://github.com/camchenry/sock.lua/r ... /tag/0.3.0
A brief changelog of some of the changes:
- Renamed 'data format' to 'schema'
- Server:setDataFormat is now Server:setSchema
- Added Client:setSchema
- Added enet's range coding compression
- Added Server:enableCompression
- Added Client:enableCompression
- Added optional code for Client:connect
- Added Server:getClientCount
- Added Server:destroy
- Added Client:reset
- Added Client:isConnected
- Added Client:isConnecting
- Added Client:isDisconnected
- Added Client:isDisconnecting
You can check out the repository here: https://github.com/camchenry/sock.lua and the documentation here: http://camchenry.com/sock.lua/
Who is online
Users browsing this forum: No registered users and 2 guests