Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make functional from clone #2

Open
diegovillafuerte1 opened this issue Nov 20, 2020 · 2 comments
Open

Make functional from clone #2

diegovillafuerte1 opened this issue Nov 20, 2020 · 2 comments

Comments

@diegovillafuerte1
Copy link

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

@fractalfantasy
Copy link

fractalfantasy commented May 4, 2021

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

@fractalfantasy
Copy link

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);
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants