mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 05:35:10 +00:00
37 lines
699 B
Lua
37 lines
699 B
Lua
local Config = require(script.Parent.Config)
|
|
local ApiContext = require(script.Parent.ApiContext)
|
|
|
|
local REMOTE_URL = ("http://localhost:%d"):format(Config.port)
|
|
|
|
local Session = {}
|
|
Session.__index = Session
|
|
|
|
function Session.new()
|
|
local self = {}
|
|
|
|
setmetatable(self, Session)
|
|
|
|
local api
|
|
|
|
api = ApiContext.new(REMOTE_URL, function(message)
|
|
if message.type == "InstanceChanged" then
|
|
print("Instance", message.id, "changed!")
|
|
-- readAll()
|
|
else
|
|
warn("Unknown message type " .. message.type)
|
|
end
|
|
end)
|
|
|
|
api:connect()
|
|
:andThen(function()
|
|
return api:read({api.rootInstanceId})
|
|
end)
|
|
:andThen(function()
|
|
return api:retrieveMessages()
|
|
end)
|
|
|
|
return self
|
|
end
|
|
|
|
return Session
|