openspace
v2.0.2
Published
open files, web sites, executables via web sockets
Downloads
4
Readme
Openspace
Open files, web sites, executables via web sockets middleware.
Install
npm i openspace --save
Client
Could be loaded from url /openspace/openspace.js
.
const prefix = '/openspace';
/* could be one argument: callback */
openspace(prefix, function(opener) {
const path = 'hello.js';
const end = () => {
console.log('end');
opener.removeListener('end', end);
};
opener.open(from, to, names);
opener.on('end', end);
opener.on('error', (error) => {
console.error(error.message);
});
});
Server
const openspace = require('openspace');
const http = require('http');
const express = require('express');
const io = require('socket.io');
const app = express();
const port = 1337;
const server = http.createServer(app);
const socket = io.listen(server);
server.listen(port);
app.use(openspace({
online: true
});
openspace.listen(socket, {
prefix: '/openspace', /* default */
root: '/', /* string or function */
authCheck: (socket, ok) => { /* optional */
/* auth check logic */
ok();
}
});
License
MIT