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: