pubsub-example
pubsub-example copied to clipboard
Make functional from clone
include instructions on installing dependencies, and hosting static files in the readme e.g. npm init npm install uNetworking/uWebSockets.js#v18.10.0 python -m http.server
yes its a bit confusing trying to figure out how to get the app running, with socket.io or uWebsockets...
typically u'd want the server to point to the client.html with express, so I'm wondering how you even serve the client file locally
I can't figure out how to get the app running locally, a typical socket.io app would look like this >> pointing to an index.html file
var app = require('http').createServer(handler)
var io = require('socket.io')(app);
var fs = require('fs');
app.listen(80);
function handler (req, res) {
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});