I'm having a strange issue where the player will connect but will be immediately timed out and will attempt to reconnect.
My code is identical to the example posted above (or close enough to it).
(Also, the steam link in the OP is broken)
LÖVE CÖNNECTION 1.4
-
- Prole
- Posts: 9
- Joined: Mon May 18, 2015 6:53 am
Re: LÖVE CÖNNECTION 1.4
OK, so I got an example to work when the client sends data to the server, but when I tried to implement the server sending to the client in a game i've been programming, it gives me an error: lib/net.lua:325: bad argument #2 to 'sendto' (string expected, got nil). I took a look at net.lua and it's missing the ip. I specified the ip like this:
It worked fine going from client to server, when I didn't specify an ip. Just a side note, incase it matters, I'm running both client and server on the same computer.
Code: Select all
Net:send( server_data, "ready", Nil, "192.168.1.69")
-
- Prole
- Posts: 49
- Joined: Sun Jun 07, 2015 9:12 am
Re: LÖVE CÖNNECTION 1.4
I'm looking into this error now, I'll let you know ASAP. I am at a friends house but I'll work on it in a few hours. Sorry for the long wait.InsertNameHere wrote:OK, so I got an example to work when the client sends data to the server, but when I tried to implement the server sending to the client in a game i've been programming, it gives me an error.
**EDIT: I've found your problem, when you're supplying the ip in net:send on the server... it's the clients --ID-- not their ip, the id is a string that is formated like this IP:PORT and deformatted like this local ip, port = id:match( "^(.-):(%d+)$" ) and then passes that to the REAL send command.. and any ids of clients kept by the server is the IP:PORT format, so you need to supply an id. Best solution is to use the net.users and loop through it, and find some sort of indicator. Because you need the port of the client connected to your server. I suggest doing it like this:
1. This will literally send this to every single client connected unless you do the second method
Code: Select all
for CLIENTSID,table in pairs( net.users ) do
Net:send( server_data, "ready", Nil, CLIENTSID)
end
Code: Select all
for CLIENTSID,table in pairs( net.users ) do
i, k = string.find( CLIENTSID, "192.168.1.69" )
if i or k then
Net:send( server_data, "ready", Nil, CLIENTSID )
end
end
-- Alternate
for CLIENTSID,table in pairs( net.users ) do
if table.name == "Nicholas Scott" then
Net:send( server_data, "ready", Nil, CLIENTSID )
end
end
Looking into this now, do you think you could dropbox the folder of all of your server code, if you don't mind. I would like to see how you run it for debugging, Please and thank you --Also thanks for informing me of the steam linklumaio wrote:I'm having a strange issue where the player will connect but will be immediately timed out and will attempt to reconnect.
(Also, the steam link in the OP is broken)
I'll look into that feature, sounds like a good one. I might receive packets 1, 2, 3 and server/client will drop packet 1, store packet 2 as LAST RECEIVED and keep packet 3 as the latest one. But as of now the end of the net code receives a command and runs it with a table that is also passed, not really any packet/storage, really just a run as it receives kind of thing. May work on this briefly, although I am kind of busy right now, I'll see though Also thanks for the compliments, I love making my code nice, neat, and if at all possible CHEAT PROOF!! Cause noone likes cheaters *Cough Cough* DAYZ... H1Z1... CS:GO... CSS... Rocket League... Minecraft( Who cares about minecraft, sorry mc lovers )... The list goes on and oncalusari wrote:Great library! Been messing around with it and it seems very promising! I love the run remote command feature.
Would like to see a feature to drop packets that are out of order
Re: LÖVE CÖNNECTION 1.4
Looks like a awesome library, but I'm having trouble connecting to any computer outside of my home network.
So, running the server and client on 1 pc works fine; running the server on my laptop and the client on my computer somewhere else in the house works fine too, but running the server on my laptop and the client on somebody else's computer somewhere else does not.
Can anybody help me out here?
Client:
Server:
So, running the server and client on 1 pc works fine; running the server on my laptop and the client on my computer somewhere else in the house works fine too, but running the server on my laptop and the client on somebody else's computer somewhere else does not.
Can anybody help me out here?
Client:
Code: Select all
Net = require "Net"
function love.load()
Net:init( "client" )
Net:connect( "212.187.101.32", 80 ) --Is it safe putting my IP on the web like that..? Sure!
timer = 0
client_data = {}
client_data.xPos = 300
client_data.yPos = 300
end
function love.update(dt)
Net:update(dt)
timer = timer + dt
if timer > 0.001 then
timer = 0
Net:send(client_data, "update", nil)
end
if love.keyboard.isDown("d") then
client_data.xPos = client_data.xPos + 100*dt
elseif love.keyboard.isDown("a") then
client_data.xPos = client_data.xPos - 100*dt
end
end
function love.draw()
love.graphics.rectangle("fill", client_data.xPos, client_data.yPos, 64, 64)
end
Code: Select all
Net = require("Net")
box = {
xPos = 0,
yPos = 0,
}
function love.load()
Net:init("server")
Net:connect(nil, 80)
Net:setMaxPing(1000)
Net:registerCMD( "update", function( client_data, param, id, deltatime )
box.xPos, box.yPos = client_data.xPos, client_data.yPos
print(box.xPos.. " " ..box.yPos)
end)
end
function love.update(dt)
Net:update(dt)
for id,data in pairs( Net:connectedUsers() ) do
print(id)
end
end
function love.draw()
love.graphics.rectangle("fill", box.xPos, box.yPos, 64, 64)
end
-
- Prole
- Posts: 34
- Joined: Mon Nov 24, 2014 9:15 pm
Re: LÖVE CÖNNECTION 1.4
How do you get mutliple connections and drawings going at once?
I was thinking of doing something like this :
I know that the net:recieve thing is probably not how you use it.
But I was wondering if you can recieve with out those weird commands and recieve from whatever id you want anytime you want it.
for example:
this probably isn't possible either, but if you could find something similar to that, this would be a good help for me.
I was thinking of doing something like this :
Code: Select all
for id,data in pairs( Net:connectedUsers() ) do
data.players.x[id] = net:recieve(...)
data.players.y[id] = net:recieve(...)
end
But I was wondering if you can recieve with out those weird commands and recieve from whatever id you want anytime you want it.
for example:
Code: Select all
for id,data in pairs( Net:connectedUsers() ) do
net:recieve(127.0.0.1, recievedData)
data.players[id] = recievedData
end
-
- Prole
- Posts: 49
- Joined: Sun Jun 07, 2015 9:12 am
Re: LÖVE CÖNNECTION 1.4
Reviving this project, check original post for details!
Re: LÖVE CÖNNECTION 1.4
Glad to hear. Is it still active?Nicholas Scott wrote: ↑Tue Aug 16, 2016 3:55 pm Reviving this project, check original post for details!
Who is online
Users browsing this forum: No registered users and 4 guests