Lua-enet, client keeps giving error no matter what I do
Posted: Mon Oct 05, 2015 1:41 am
I, I'm trying to make a little server which could receive a packed table as a string, unpack it, calculate stuff on it and return it as a packed table. The problem is that i've used this tutorial http://leafo.net/lua-enet/#tutorial and tried to adapt it to love with the callbacks.
This is the code i ''made'':
Server:
Client:
When I try to launch the server, it works properly, it shows this
and when i launch the client it gives this
But the client becomes:
This is the code i ''made'':
Server:
Code: Select all
require('enet')
message ='Default message!'
local host = enet.host_create("localhost:6789")
function love.update(dt)
local event = host:service(100)
if event then
if event.type == "receive" then
message = "Got message: "..event.data
event.peer:send( "pong" )
elseif event.type == "connect" then
message = " connected." ..event.data
elseif event.type == "disconnect" then
message = " disconnected."
end
event = host:service()
end
end
function love.draw()
love.graphics.setColor(255, 255, 255)
love.graphics.print(message,100,100)
end
Code: Select all
require('enet')
port = 25565
host = enet.host_create()
server = host:connect("localhost:6789")
function love.update(dt)
local done = false
event = host:service(100)
event.peer:send("hello SERVER") --LINE 12
if event then
if event.type == "connect" then
print("Connected to", event.peer)
event.peer:send("hello SERVE, IM CONNECTED")
elseif event.type == "receive" then
print("Got message from server: ", event.data, event.peer)
done = true
end
end
end
and when i launch the client it gives this
But the client becomes: