UNPKG

lx-scan

Version:

License eXtension to find 5-tuples of all installed packages: name, version, project home page, license (e. g. Apache v2, BSD) and required notice. It includes a GUI to edit information for each package and to enter information if necessary.

34 lines (32 loc) 948 B
// Elements in the output array are of the form: // {type: <string>,action: <function (socket) >}; // type is the message type (provided by client) to which // the function will respond var socketActions = function(app,io,routes) { return [ { type: "scanreq", action: function (socket) { return function (message_from_browser) { message_from_browser.jfiles = app.locals.jfiles; routes.scan.io(message_from_browser,function (err,jfile,path) { if(err) { io.to(socket.id).emit("error",{msg: err.toString()}); } else { app.locals.jfiles[jfile] = path; io.to(socket.id).emit("scandone",{msg: jfile}); } }); }; } } ]; }; module.exports = function(app,io,routes) { var actions = socketActions(app,io,routes); io.on("connection", function (socket) { actions.forEach(function (input) { socket.on(input.type,input.action(socket)); }); }); };