-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign the protocol to use a capability system
- The protocol now uses JSON instead of a quasi-binary format. While the former is more efficient to produce, the difference is pretty marginal. This helps simplify packet encoding/decoding. - All clients connect through the /connect endpoint, providing a session id (aka token) and list of capabilities. - Specific packets can only be sent to clients with a given capability. For instance, terminal packets are only sent to clients with the terminal:view capability, while file action packets are sent to both file:edit and file:host clients. This is mostly intended to allow greater flexibility in the future, such as a desktop-based file syncing program.
- Loading branch information
Showing
15 changed files
with
1,154 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
local function mk_fields(fields) | ||
local out = {} | ||
for i = 1, #fields do out[fields[i]] = {} end | ||
return { fields = out } | ||
end | ||
|
||
std = { | ||
read_globals = { | ||
fs = mk_fields { "makeDir", "complete", "copy", "isDir", "list", "getSize", "delete", "isReadOnly", "getFreeSpace", "find", "getDrive", "exists", "move", "combine", "getName", "getDir", "open" }, | ||
colours = mk_fields { "cyan", "purple", "brown", "lightGrey", "orange", "red", "magenta", "blue", "white", "grey", "rgb8", "pink", "test", "subtract", "black", "green", "combine", "yellow", "lime", "lightBlue" }, | ||
tostring = {}, | ||
_CC_DEFAULT_SETTINGS = {}, | ||
getfenv = {}, | ||
debug = mk_fields { "getupvalue", "debug", "getfenv", "getmetatable", "gethook", "setmetatable", "setfenv", "traceback", "getinfo", "setlocal", "setupvalue", "sethook", "getregistry", "getlocal" }, | ||
disk = mk_fields { "getID", "isPresent", "eject", "getMountPath", "stopAudio", "getLabel", "hasAudio", "playAudio", "getAudioTitle", "setLabel", "hasData" }, | ||
assert = {}, | ||
tonumber = {}, | ||
io = mk_fields { "lines", "write", "close", "flush", "open", "output", "read", "input", "type" }, | ||
redstone = mk_fields { "setAnalogOutput", "getBundledOutput", "getBundledInput", "setOutput", "setAnalogueOutput", "getInput", "getOutput", "setBundledOutput", "getAnalogueOutput", "testBundledInput", "getSides", "getAnalogInput", "getAnalogOutput", "getAnalogueInput" }, | ||
load = {}, | ||
http = mk_fields { "checkURLAsync", "websocketAsync", "checkURL", "request", "websocket", "post", "get" }, | ||
_G = { | ||
read_only = false, | ||
other_fields = true, | ||
}, | ||
peripheral = mk_fields { "call", "isPresent", "getType", "getMethods", "wrap", "find", "getNames" }, | ||
vector = mk_fields { "new" }, | ||
term = mk_fields { "getCursorPos", "isColour", "getBackgroundColor", "getTextColour", "scroll", "redirect", "getPaletteColor", "setTextColor", "native", "setPaletteColour", "getTextColor", "clear", "write", "setPaletteColor", "setCursorPos", "getBackgroundColour", "isColor", "setTextColour", "blit", "current", "getSize", "getPaletteColour", "setCursorBlink", "setBackgroundColor", "setBackgroundColour", "clearLine" }, | ||
coroutine = mk_fields { "running", "yield", "status", "wrap", "create", "resume" }, | ||
textutils = mk_fields { "serialize", "unserialize", "empty_json_array", "serializeJSON", "urlEncode", "serialiseJSON", "complete", "serialise", "formatTime", "pagedTabulate", "slowWrite", "slowPrint", "pagedPrint", "tabulate", "unserialise" }, | ||
loadstring = {}, | ||
rednet = mk_fields { "CHANNEL_REPEAT", "isOpen", "unhost", "close", "send", "open", "host", "CHANNEL_BROADCAST", "broadcast", "run", "receive", "lookup" }, | ||
_HOST = {}, | ||
string = mk_fields { "sub", "find", "len", "gfind", "reverse", "rep", "match", "gmatch", "dump", "byte", "upper", "gsub", "format", "char", "lower" }, | ||
xpcall = {}, | ||
package = { | ||
fields = { | ||
preload = {}, | ||
config = {}, | ||
loaders = {}, | ||
loaded = { | ||
read_only = false, | ||
other_fields = true, | ||
}, | ||
path = {}, | ||
}, | ||
}, | ||
parallel = mk_fields { "waitForAll", "waitForAny" }, | ||
print = {}, | ||
unpack = {}, | ||
__inext = {}, | ||
printError = {}, | ||
require = {}, | ||
_ENV = { | ||
read_only = false, | ||
other_fields = true, | ||
}, | ||
write = {}, | ||
next = {}, | ||
ipairs = {}, | ||
rawequal = {}, | ||
getmetatable = {}, | ||
sleep = {}, | ||
loadfile = {}, | ||
settings = mk_fields { "clear", "unset", "set", "getNames", "save", "load", "get" }, | ||
rawset = {}, | ||
dofile = {}, | ||
bit32 = mk_fields { "band", "rshift", "bor", "bnot", "bxor", "arshift", "btest", "lrotate", "lshift", "replace", "rrotate", "extract" }, | ||
pairs = {}, | ||
rs = mk_fields { "setAnalogOutput", "getBundledOutput", "getBundledInput", "setOutput", "setAnalogueOutput", "getInput", "getOutput", "setBundledOutput", "getAnalogueOutput", "testBundledInput", "getSides", "getAnalogInput", "getAnalogOutput", "getAnalogueInput" }, | ||
help = mk_fields { "path", "topics", "completeTopic", "setPath", "lookup" }, | ||
window = mk_fields { "create" }, | ||
math = mk_fields { "log", "ceil", "atan", "acos", "ldexp", "rad", "pow", "asin", "pi", "deg", "tan", "cos", "tanh", "random", "abs", "frexp", "log10", "floor", "sinh", "max", "sqrt", "modf", "huge", "min", "mod", "fmod", "randomseed", "atan2", "exp", "sin", "cosh" }, | ||
_VERSION = {}, | ||
pcall = {}, | ||
keys = mk_fields { "a", "c", "b", "e", "pageUp", "g", "f", "i", "h", "k", "j", "space", "l", "o", "n", "q", "f1", "s", "insert", "u", "t", "eight", "numPadEnter", "six", "x", "numPad6", "z", "backslash", "rightBracket", "f9", "yen", "left", "numPadSubtract", "noconvert", "grave", "rightCtrl", "numPad2", "rightAlt", "delete", "f4", "home", "leftAlt", "numPad8", "getName", "numLock", "f8", "r", "pageDown", "y", "numPadEquals", "at", "pause", "w", "f11", "slash", "f5", "rightShift", "period", "multiply", "numPad0", "nine", "f13", "capsLock", "two", "leftBracket", "minus", "scollLock", "colon", "f14", "v", "equals", "three", "up", "d", "convert", "f7", "apostrophe", "f15", "f10", "stop", "f2", "numPad3", "comma", "numPad1", "numPadAdd", "tab", "f3", "numPad4", "kana", "four", "right", "numPadDecimal", "numPad7", "leftShift", "backspace", "numPad9", "end", "one", "kanji", "cimcumflex", "m", "semiColon", "underscore", "zero", "p", "return", "ax", "seven", "f6", "enter", "numPadDivide", "numPad5", "f12", "leftCtrl", "down", "five", "numPadComma" }, | ||
gps = mk_fields { "CHANNEL_GPS", "locate" }, | ||
bit = mk_fields { "band", "blogic_rshift", "bxor", "bor", "bnot", "blshift", "brshift" }, | ||
select = {}, | ||
paintutils = mk_fields { "drawPixel", "drawLine", "loadImage", "drawImage", "drawFilledBox", "parseImage", "drawBox" }, | ||
os = mk_fields { "sleep", "unloadAPI", "getComputerID", "startTimer", "queueEvent", "cancelTimer", "time", "clock", "setAlarm", "computerID", "reboot", "getComputerLabel", "setComputerLabel", "run", "pullEventRaw", "cancelAlarm", "computerLabel", "version", "shutdown", "loadAPI", "pullEvent", "epoch", "day" }, | ||
rawget = {}, | ||
table = mk_fields { "pack", "insert", "getn", "foreachi", "maxn", "foreach", "sort", "unpack", "concat", "remove" }, | ||
read = {}, | ||
colors = mk_fields { "cyan", "purple", "brown", "orange", "red", "magenta", "lime", "white", "blue", "rgb8", "lightGray", "pink", "test", "subtract", "black", "green", "combine", "yellow", "lightBlue", "gray" }, | ||
setfenv = {}, | ||
setmetatable = {}, | ||
type = {}, | ||
error = {}, | ||
shell = mk_fields { "exit", "path", "setDir", "clearAlias", "programs", "dir", "getCompletionInfo", "resolveProgram", "setPath", "getRunningProgram", "setCompletionFunction", "history", "run", "complete", "completeProgram", "resolve", "setAlias", "aliases" }, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.