mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Plugin: Pipe InstanceMap around, improve debug output, fix session ID bug
This commit is contained in:
parent
463bf9b116
commit
bdaa671823
5 changed files with 52 additions and 13 deletions
|
|
@ -87,7 +87,7 @@ function ApiContext.new(baseUrl)
|
|||
|
||||
local self = {
|
||||
__baseUrl = baseUrl,
|
||||
__serverId = nil,
|
||||
__sessionId = nil,
|
||||
__messageCursor = -1,
|
||||
__connected = true,
|
||||
}
|
||||
|
|
@ -95,6 +95,19 @@ function ApiContext.new(baseUrl)
|
|||
return setmetatable(self, ApiContext)
|
||||
end
|
||||
|
||||
function ApiContext:__fmtDebug(output)
|
||||
output:writeLine("ApiContext {{")
|
||||
output:indent()
|
||||
|
||||
output:writeLine("Connected: {}", self.__connected)
|
||||
output:writeLine("Base URL: {}", self.__baseUrl)
|
||||
output:writeLine("Session ID: {}", self.__sessionId)
|
||||
output:writeLine("Message Cursor: {}", self.__messageCursor)
|
||||
|
||||
output:unindent()
|
||||
output:write("}")
|
||||
end
|
||||
|
||||
function ApiContext:disconnect()
|
||||
self.__connected = false
|
||||
end
|
||||
|
|
@ -117,7 +130,7 @@ function ApiContext:connect()
|
|||
end)
|
||||
:andThen(rejectWrongPlaceId)
|
||||
:andThen(function(body)
|
||||
self.__serverId = body.serverId
|
||||
self.__sessionId = body.sessionId
|
||||
|
||||
return body
|
||||
end)
|
||||
|
|
@ -130,7 +143,7 @@ function ApiContext:read(ids)
|
|||
:andThen(rejectFailedRequests)
|
||||
:andThen(Http.Response.json)
|
||||
:andThen(function(body)
|
||||
if body.serverId ~= self.__serverId then
|
||||
if body.sessionId ~= self.__sessionId then
|
||||
return Promise.reject("Server changed ID")
|
||||
end
|
||||
|
||||
|
|
@ -162,7 +175,7 @@ function ApiContext:retrieveMessages()
|
|||
:andThen(rejectFailedRequests)
|
||||
:andThen(Http.Response.json)
|
||||
:andThen(function(body)
|
||||
if body.serverId ~= self.__serverId then
|
||||
if body.sessionId ~= self.__sessionId then
|
||||
return Promise.reject("Server changed ID")
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue