I am currently thinking of a way to improve Löve's networking capabilities and propose an API for it. Any comments or suggestions would be welcome. Also whether there is an actual interest in such an API in Löve could encourage me to actually complete my current implementation.
Currently in Löve there is support for raw tcp or udp sockets, which combined with bartbes' LUBE is quite usable but it still mostly is raw tcp and udp.
On the other hand there is e-net, which is a nice light-weight networking library that is based on udp but also lets you do the things that tcp provides, but on a per-packet basis. For e-net there is also a nice lua wrapper for its api available (thanks to Leafo).
While LUBE has a nicer and more concise API (in my opinion) it suffers from some features that e-net provides (i.e. reliable / unreliable packets, keeping track of pings, channels over the same connection). However the API of e-net is rather general and not entirely intuitive.
All the approaches are okay, but in my opinion something simpler would be nice to have in Löve. I would therfore propose an extension to Löve which is based on e-net, which exposes a simpler and more concise API to networking, that should simplify making networked games.
Code: Select all
-- Server
server = net.newServerSocket(
address, connect_callback, receive_callback, disconnect_callback,
[max_client_count = 16, channel_count = 8,
incoming_bandwidth, outgoing_bandwidth])
server_connect_callback (client_info)
server_receive_callback (client_info, channel, data)
server_disconnect_callback (client_info)
server:service([timeout]) -- processes all packets and
-- executes callbacks
server:getClientInfo (client_info.id)
server:getPing (client_info.id)
server:send (client_info.id, data, [channel = 1], [flags = reliable])
server:sendAll (data, [channel = 1], [flags = reliable])
server:disconnect (client_info.id)
-- Client
client = net.newClientSocket(
connect_callback, receive_callback, disconnect_callback,
[channel_count = 8, incoming_bandwidth, outgoing_bandwidth]
)
client:connect (address)
client_connect_callback (server_info)
client_receive_callback (channel, data)
client_disconnect_callback (server_info)
client:send (data, [channel = 1], [flags = reliable])
client:getPing ()
client:disconnect()
Comments? Interest?