summaryrefslogblamecommitdiff
path: root/main.lua
blob: 40acc5b21713549408e543979fc4241e477b54c0 (plain) (tree)
1
2
3
4
5
6
7
8
9


                                         
                           
         

                                 

 
                                                           



                                  

                                                                                 
                

   
                         
                 

   
                                                         
local funsaac = RegisterMod("funsaac", 1)
local json = require("json")

local requestServerInfo = {
  Id = 1,
  ClientName = "Funsaac v.0.0.1",
  MessageVersion = 3
}

local client = require("websocket").new("127.0.0.1", 12345)
function client:onmessage(message)
  print(message)
end
function client:onopen()
  local msg = '[{"RequestServerInfo": ' .. json.encode(requestServerInfo) .. "}]"
  print(msg)
  self:send(msg)
end

local function onUpdate()
  client:update()
end

funsaac:AddCallback(ModCallbacks.MC_POST_UPDATE, onUpdate)