title: uWebSockets - push events to server
body: <p>I have a uWebSockets server as it seems to be a lot more performance friendly than socket.io servers.
  So I have a server and its connected fine and after some trouble I got the index.html client side to connect, but now I'm not able to push events to the server from the client side. What am I doing wrong?</p>
  
  <pre><code>var WebSocketServer = require('uws').Server,
      express         = require('express'),
      path            = require('path'),
      app             = express(),
      server          = require('http').createServer(),
      createEngine    = require('node-twig').createEngine;
  
  var wss = new WebSocketServer({server: server});
  
  wss.on('connection', function (ws) {
  
      ws.on('join', function (value) {
          console.log('SOMEONE JUST JOINED');
      });
  
      ws.on('close', function () {
          //console.log('stopping client interval');
          clearInterval(id);
      });
  });
  
  server.on('request', app);
  
  server.listen(8080, function () {
      console.log('Listening on http://localhost:8080');
  });
  </code></pre>
  
  <p>index.html</p>
  
  <pre><code>&lt;script&gt;
        var host = window.document.location.host.replace(/:.*/, '');
        var server = new WebSocket('ws://' + host + ':8080');
        server.onmessage = function (event) {
          updateStats(JSON.parse(event.data));
        };
  
        server.onopen = function (event) {
          server.send("Here's some text that the server is urgently awaiting!");
          server.send('join');
        };
  
        function something() {
          console.log('WORKED');
          server.send('join');
        }
  
      &lt;/script&gt;
  </code></pre>