console添加切换服务器的命令

This commit is contained in:
MrZ626
2021-05-30 16:21:03 +08:00
parent 59ef90e120
commit 25ad789e61
2 changed files with 35 additions and 0 deletions

View File

@@ -233,6 +233,15 @@ local wsList=setmetatable({},{
end
})
function WS.switchHost(_1,_2,_3)
for k in next,wsList do
WS.close(k)
end
host=_1
port=_2 or port
path=_3 or path
end
function WS.connect(name,subPath,body,timeout)
local ws={
real=true,

View File

@@ -236,6 +236,18 @@ do--commands.help(arg)
"Usage: test",
},
},
switchhost={
description="Switch another host",
details={
"Disconnect all connections and switch to another host",
"",
"Usage:",
"switchhost [host]",
"switchhost [host] [port]",
"switchhost [host] [port] [path]",
"Example: switchhost 127.0.0.1 26000 /sock",
},
},
applet={
description="Go to an applet scene",
details={
@@ -275,6 +287,7 @@ do--commands.help(arg)
"setbg",
"theme",
"test",
"switchhost",
"applet",
}
function commands.help(arg)
@@ -583,6 +596,19 @@ end
function commands.test()
SCN.go('test','none')
end
function commands.switchhost(arg)
arg=STRING.split(arg," ")
if arg[1]and #arg<=3 then
WS.switchHost(unpack(arg))
log{C.Y,"Host switched"}
else
log{C.A,"Usage:"}
log{C.A,"switchhost [host]"}
log{C.A,"switchhost [host] [port]"}
log{C.A,"switchhost [host] [port] [path]"}
log{C.A,"Example: switchhost 127.0.0.1 26000 /sock"}
end
end
do--commands.applet(name)
local appList={"15p","grid","pong","atoz","uttt","cube","2048","ten","tap","dtw","cannon","dropper","calc","reflect","polyforge"}
local appScene={'app_15p','app_schulteG','app_pong','app_AtoZ','app_UTTT','app_cubefield','app_2048','app_ten','app_tap','app_dtw','app_cannon','app_dropper','app_calc','app_reflect','app_polyforge'}