Created
March 8, 2015 09:33
-
-
Save sassembla/fb238325d1bcd32992e2 to your computer and use it in GitHub Desktop.
nginx + lua で複数クライアント接続での合同contextみたいなやつ
This file contains hidden or 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
--[[] | |
ゲームとか書けるところ。あとコンテキストの名の通り、データベースに依存せずにパラメータとか持てるぞ。 | |
]] | |
local M = {} | |
function M.onConnect(from, publish) | |
ngx.log(ngx.ERR, "connect from:", from) | |
end | |
function M.onMessage(from, data, publish) | |
-- do something here. | |
ngx.log(ngx.ERR, "message from:", from, " data:", data) | |
-- publish(data, to) | |
-- publish(data, to1, to2, ,,,) | |
-- publish(data) | |
publish(data) | |
end | |
function M.onDisconnect(from, reason, publish) | |
ngx.log(ngx.ERR, "disconnect from:", from, " reason:", reason) | |
end | |
-- 100f/secくらい、ただし、すべてのルームが同期で動く。 | |
function M.onFrame(publish) | |
end | |
return M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/sassembla/nginx-luajit
ここから実装をCとかC++だけに持っていく。今は起動通信が一発必要なので、そのへんの自動化とか。