Page 2 of 3
Re: Status of Multiplayer Mobile Networking
Posted: Sat May 19, 2018 8:05 pm
by SmartGlassesMan
zorg wrote: ↑Sat May 19, 2018 7:56 pm
And again, you don't need to do anything yourself regarding Enet, it's bundled into löve, like how luasocket is. You just
and it works.
Ah. There must be something wrong with my sock.lua code then. I got an error about enet being nil, and I went down the path of thinking it was because I hadn't installed enet.
Thanks.
Code: Select all
-- server.lua
sock = require "sock"
function love.load()
-- Creating a server on any IP, port 22122
server = sock.newServer("*", 22122)
-- Called when someone connects to the server
server:on("connect", function(data, client)
-- Send a message back to the connected client
local msg = "Hello from the server!"
client:send("hello", msg)
end)
end
function love.update(dt)
server:update()
end
I must be using sock.lua wrong.
Thanks for the information!
Re: Status of Multiplayer Mobile Networking
Posted: Sat May 19, 2018 8:09 pm
by zorg
I don't know any sock.lua, but if it's using enet from before 0.11 nightlies, then it might still expect enet to set a global variable (called enet) and expects it to work like that; it doesn't anymore, that was bad coding style. You can check and just edit it so it'll be a file-local instead.
Re: Status of Multiplayer Mobile Networking
Posted: Sat May 19, 2018 8:18 pm
by SmartGlassesMan
zorg wrote: ↑Sat May 19, 2018 8:09 pm
I don't know any sock.lua, but if it's using enet from before 0.11 nightlies, then it might still expect enet to set a global variable (called enet) and expects it to work like that; it doesn't anymore, that was bad coding style. You can check and just edit it so it'll be a file-local instead.
Nice. I'll try it.
Re: Status of Multiplayer Mobile Networking
Posted: Sat May 19, 2018 8:25 pm
by 4aiman
Sock.lua is a great lib!
(what zorg said) True, the 11.x the "enet" global variable doesn't get registered automatically. One have to do
Other than that you may want to double check the IP you're running server at. Or just use "*" to allow any IP.
With that in mind it shouldn't be too difficult to send some messages.
On a side note, you may want to learn about threads as sending some huge data (say, upon connection of a new client which doesn't have any cache stored) will hinder any other message processing.
What I did was:
- connect to a server, check for content updates
- if there are updates, the server answers with an IP:port of another server to connect to and creates it (the new server)
- the client then disconnects from the main server and connects to the given IP:port where it can easily get an update of any size
- upon completion, the client can re-connect to the main server
That ^ by no means is a perfect way to get some huge data, but it has worked for me so far
Anyway, people here will be able to correct me.
Cheers.
Re: Status of Multiplayer Mobile Networking
Posted: Sat May 19, 2018 8:30 pm
by SmartGlassesMan
zorg wrote: ↑Sat May 19, 2018 8:09 pm
I don't know any sock.lua, but if it's using enet from before 0.11 nightlies, then it might still expect enet to set a global variable (called enet) and expects it to work like that; it doesn't anymore, that was bad coding style. You can check and just edit it so it'll be a file-local instead.
I think that worked to get past the first error.
I changed the following line in sock.lua
to
The server code in the above post now seems to run without any errors. Certainly no errors thrown yet.
Now, if I can just get past the client code error I'm getting.
Thanks again for your help.
Re: Status of Multiplayer Mobile Networking
Posted: Sat May 19, 2018 8:47 pm
by SmartGlassesMan
4aiman wrote: ↑Sat May 19, 2018 8:25 pm
On a side note, you may want to learn about threads as sending some huge data (say, upon connection of a new client which doesn't have any cache stored) will hinder any other message processing.
What I did was:
- connect to a server, check for content updates
- if there are updates, the server answers with an IP:port of another server to connect to and creates it (the new server)
- the client then disconnects from the main server and connects to the given IP:port where it can easily get an update of any size
- upon completion, the client can re-connect to the main server
That ^ by no means is a perfect way to get some huge data, but it has worked for me so far
Big data is a bit beyond my current project stage (just starting) but that may be some good advice for later on.
Thanks.
Re: Status of Multiplayer Mobile Networking
Posted: Sun May 20, 2018 4:58 am
by ivan
zorg wrote: ↑Sat May 19, 2018 7:00 pm
SmartGlassesMan wrote: ↑Sat May 19, 2018 6:48 pm
Thanks for the reply. That's helpful information.
No it's not, when it gets misinterpreted.
Sure, enet and luasocket are cross platform.
However, you are still going to need some sort of authentication -
which is usually handled through Andoid/iOS (I don't think you can interface with these from Lua/FFI).
Re: Status of Multiplayer Mobile Networking
Posted: Sun May 20, 2018 7:52 am
by SmartGlassesMan
ivan wrote: ↑Sun May 20, 2018 4:58 am
Yep, enet and luasocket are cross platform.
However, you are still going to need some sort of authentication -
which is usually handled through Andoid/iOS (I don't think you can interface with these from Lua/FFI).
Good point. Yes, there is much more to networking than just access to a low-level networking library.
They corrected my misconception about how to use enet, though.
Re: Status of Multiplayer Mobile Networking
Posted: Mon May 21, 2018 3:58 pm
by Ikroth
SmartGlassesMan wrote: ↑Sat May 19, 2018 8:30 pm
zorg wrote: ↑Sat May 19, 2018 8:09 pm
I don't know any sock.lua, but if it's using enet from before 0.11 nightlies, then it might still expect enet to set a global variable (called enet) and expects it to work like that; it doesn't anymore, that was bad coding style. You can check and just edit it so it'll be a file-local instead.
I think that worked to get past the first error.
I changed the following line in sock.lua
to
The server code in the above post now seems to run without any errors. Certainly no errors thrown yet.
Now, if I can just get past the client code error I'm getting.
Thanks again for your help.
Thanks for reporting that, I just pushed a fix that exports enet as a local instead. I didn't like the global style before either. Let me know if you have other issues, I haven't done a full check since 11.0.
Re: Status of Multiplayer Mobile Networking
Posted: Mon May 21, 2018 8:05 pm
by Pebsie
It's pretty much the same as Windows networking, you've just gotta be super conscious of data usage and dealing with network drop outs.
Here's a game I'm working on that is entirely network oriented that is going to be released on mobile platforms:
viewtopic.php?f=14&t=85025&p=219410#p219410
It can be done and is being done!