Skip to content

flaribbit/love2d-lua-websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

websocket client pure lua implement for love2d

Event-driven websocket client for love2d in pure lua.

Not all websocket features are implemented, but it works fine.

Quick start

local client = require("websocket").new("127.0.0.1", 5000)
client.onmessage = function(message)
    print(message)
end
client.onopen = function()
    client:send("hello from love2d")
    client:close()
end
client.onclose = function()
    print("closed")
end

function love.update()
    client:update()
end

API

  • websocket.new(host: string, port: int, path?: string) -> client
  • client.onopen = function()
  • client.onmessage = function(message: string)
  • client.onclose = function(closecode?: int, reason?: int)
  • client.status -> int