Closed nneves closed 11 years ago
http://127.0.0.1:8080/api/getfilelistgcode/
request response: {"response":true}
Data fetch process will be asynchronous and will trigger a UI callback with data:
{"filelistgcode":[{"filename":"3D_Knot.gcode","extension":"gcode","filesize":1670110},{"filename":"calibrate.gcode","extension":"gcode","filesize":369},{"filename":"demo.gcode","extension":"gcode","filesize":1758},{"filename":"test.gcode","extension":"gcode","filesize":2642}]}
http://127.0.0.1:8080/api/getfileliststl/
request response: {"response":true}
Data fetch process will be asynchronous and will trigger a UI callback with data:
{"fileliststl":[{"filename":"SteeringArm_l.stl","extension":"stl","filesize":172626}]}
After the async rest request gets called from [rest.js] it will then run [mainapp.js] mainapp.getFileList("GCODE"); that will do an async system file list. When file list is completed, [mainapp.js] will then emit events on the printer output stream channel (printercore.oStreamPrinter) and will then follow the normal workflow (mainapp.printercore.oStreamPrinter -> rest.jsonStream -> Socket.IO channel -> Client).
From client side, printer.js as now a possibility to map callbacks to Socket.IO events:
// index.html
var cbPrinterMessages = function (data) {
var datastring = JSON.stringify(data);
alert(datastring);
}
var printer = PRINTER.WebInterface();
printer.cblist.response = cbPrinterMessages;
printer.cblist.printer = cbPrinterMessages;
printer.cblist.error = cbPrinterMessages;
printer.cblist.filelistgcode = cbPrinterMessages;
printer.cblist.fileliststl = cbPrinterMessages;
Note: Each event can have its own callback.
Need to list the cache GCODE and STL files. This will be required by the UI/front-end webapp to be able to select a specific file to be converter / printed.