CoronaSDK/LUA client for colyseus - a Minimalist Multiplayer Game Server.
There's a sample project on coronasdk-example, which connects to a simple chat application demo.
local colyseus = require('colyseus')
local client = colyseus.connect('ws://localhost:2657');
local roomName = "room_name"
local room = client:join(roomName)
client:on('open', function()
print("connected successfully:", client.id)
end)
room:on('join', function()
print(client.id, "joined", roomName)
room:send({ message = "I'm connected!" })
end)
room:on('error', function()
print(client.id, "couldn't join", roomName)
end)
room:on('leave', function()
print(client.id, "left", roomName)
end)
room:on('data', function(data)
print(client.id, "received on", roomName, data)
end)
room:on('patch', function(patches)
print(roomName, "will apply these changes:", patches)
})
room:on('update', function(newState, patches)
print(roomName, "new state:", newState, "changes applied:", patches)
end)
You will need to let Corona play nice with luarocks
, which is a powerful
package manager for the LUA programming language.
- Download and install luarocks.
- Install luarocks package
inside your source directory. (
luarocks install luarocks --tree=src/luarocks
) - Install colyseus package inside
your source directory. (
luarocks install colyseus --tree=src/luarocks
) - Download and copy dmc_corona into your source directory.
- Add openssl and
bit plugins to your project.
(inside
build.settings
file, plugins section)
Add this little piece of code at the very top of your main.lua
file:
-- Integration with luarocks
package.path = string.gsub(system.pathForFile('luarocks/bin/luarocks', system.ResourceDirectory), 'bin/luarocks', '') .. 'share/lua/5.2/?.lua' .. ';' .. package.path
require("luarocks.loader")
Finally, your source directory should look like this: (only relevant files)
▾ source-files/
▸ luarocks/
▸ dmc_corona/
dmc_corona.cfg
dmc_corona_boot.lua
build.settings
main.lua
Dependencies
MIT