mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-24 06:34:09 +00:00
Make plugin look for ROJO_AUTOSTART_PORT for automatic session start
This commit is contained in:
parent
ff0a830e0c
commit
1d2d2a85d1
1 changed files with 36 additions and 21 deletions
|
|
@ -79,6 +79,40 @@ function App:init()
|
||||||
or Version.display(Config.version)
|
or Version.display(Config.version)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function App:startSession(address, port)
|
||||||
|
Logging.trace("Starting new session")
|
||||||
|
|
||||||
|
local success, session = Session.new({
|
||||||
|
address = address,
|
||||||
|
port = port,
|
||||||
|
onError = function(message)
|
||||||
|
Logging.warn("Rojo session terminated because of an error:\n%s", tostring(message))
|
||||||
|
self.currentSession = nil
|
||||||
|
|
||||||
|
self:setState({
|
||||||
|
sessionStatus = SessionStatus.Disconnected,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
if success then
|
||||||
|
self.currentSession = session
|
||||||
|
self:setState({
|
||||||
|
sessionStatus = SessionStatus.Connected,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function App:checkAutostart()
|
||||||
|
-- Rojo supports automatically starting the a session if a special marker
|
||||||
|
-- value is present. It specifies the port to connect to in the case of
|
||||||
|
-- multiple instances running at the same time.
|
||||||
|
local autostartPort = game:FindFirstChild("ROJO_AUTOSTART_PORT")
|
||||||
|
if autostartPort ~= nil then
|
||||||
|
self:startSession("localhost", autostartPort.Value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function App:render()
|
function App:render()
|
||||||
local children
|
local children
|
||||||
|
|
||||||
|
|
@ -102,27 +136,7 @@ function App:render()
|
||||||
children = {
|
children = {
|
||||||
ConnectPanel = e(ConnectPanel, {
|
ConnectPanel = e(ConnectPanel, {
|
||||||
startSession = function(address, port)
|
startSession = function(address, port)
|
||||||
Logging.trace("Starting new session")
|
self:startSession(address, port)
|
||||||
|
|
||||||
local success, session = Session.new({
|
|
||||||
address = address,
|
|
||||||
port = port,
|
|
||||||
onError = function(message)
|
|
||||||
Logging.warn("Rojo session terminated because of an error:\n%s", tostring(message))
|
|
||||||
self.currentSession = nil
|
|
||||||
|
|
||||||
self:setState({
|
|
||||||
sessionStatus = SessionStatus.Disconnected,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
if success then
|
|
||||||
self.currentSession = session
|
|
||||||
self:setState({
|
|
||||||
sessionStatus = SessionStatus.Connected,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
cancel = function()
|
cancel = function()
|
||||||
Logging.trace("Canceling session configuration")
|
Logging.trace("Canceling session configuration")
|
||||||
|
|
@ -180,6 +194,7 @@ function App:didMount()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
preloadAssets()
|
preloadAssets()
|
||||||
|
self:checkAutostart()
|
||||||
end
|
end
|
||||||
|
|
||||||
function App:willUnmount()
|
function App:willUnmount()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue