Add plugin half of script-only, existing-instance-only, two way sync

This commit is contained in:
Lucien Greathouse
2019-12-18 17:39:04 -08:00
parent e83437c193
commit cfff08cdfd
4 changed files with 95 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
local Http = require(script.Parent.Parent.Http)
local Log = require(script.Parent.Parent.Log)
local Promise = require(script.Parent.Parent.Promise)
local Config = require(script.Parent.Config)
@@ -153,6 +154,23 @@ function ApiContext:read(ids)
end)
end
function ApiContext:write(patch)
local url = ("%s/write"):format(self.__baseUrl)
local body = Http.jsonEncode({
sessionId = self.__sessionId,
patch = patch,
})
return Http.post(url, body)
:andThen(rejectFailedRequests)
:andThen(Http.Response.json)
:andThen(function(body)
Log.info("Write response: {:?}", body)
return body
end)
end
function ApiContext:retrieveMessages()
local url = ("%s/api/subscribe/%s"):format(self.__baseUrl, self.__messageCursor)