diff --git a/core.lua b/core.lua index 5e97e45..3e55666 100644 --- a/core.lua +++ b/core.lua @@ -8,6 +8,10 @@ function Core:new() end function Core:connect() + if not self then + error("No instance!") + end + ws, err = assert(http.websocket("ws://192.168.5.162:8080")); if not ws then @@ -20,6 +24,10 @@ function Core:connect() end function Core:send(package) + if not self then + error("No instance!") + end + if not package then return false, "Missing package"; end @@ -32,14 +40,22 @@ function Core:send(package) end function Core:read() + if not self then + error("No instance!") + end + if not self.ws then return false, "Websocket not initiated"; end - return true, textutils.unserialiseJSON(self.ws.read()) + return true, textutils.unserialiseJSON(self.ws.receive()) end function Core:download(file) + if not self then + error("No instance!") + end + if not self.ws then return false, "Websocket not initiated"; end