Last active
December 12, 2015 04:59
-
-
Save udoprog/4718743 to your computer and use it in GitHub Desktop.
example network support in love
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- code for love.network can be found at https://bitbucket.org/udoprog/love-network | |
function socketError(s, reason) | |
print("socket error: " .. reason) | |
end | |
function socketRead(s, data) | |
print("socket read: " .. data) | |
end | |
function socketState(s, state) | |
print("socket state: " .. state) | |
if state == "connected" then | |
s:send("Oh hi, nice to see you again!\n") | |
else | |
s:connect("localhost", "1234") | |
end | |
end | |
function love.load() | |
s = love.network.newTcpSocket() | |
s:setCallbacks(socketRead, socketError, socketState) | |
s:connect("localhost", "1234") | |
end | |
function love.draw() | |
love.graphics.print("Hello World", 10, 10) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment