A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/18343509/hapi-js-with-socket-io-where-is-socket-io-js below:

node.js - Hapi.js with Socket.io -- Where is socket.io.js?

Hapi 8 has introduced some new intricacies so if anyone if revisiting this issue...

On the client, you don't have to use /socket.io/socket.io.js, instead use

  1. a cdn (https://cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js)
  2. or serve the file more specifically (http://yoursite.io/js/socket.io/socket.io.js)
  3. Better yet, use something like npm/browserify and (https://www.npmjs.com/package/socket.io-client):

    var socket = require('socket.io-client')('http://localhost:8080');

Which ever way you choose to include the client side code above

Hapi 8 will allow you to do something cool on your server with chat like this:

server.js

server.connection({ port: 8000, labels: 'app' });
server.connection({ port: 8080, labels: 'chat' });
server.register({
    register: require('./server/plugins/socketIO')
}, 
function(err) {
    if (err) throw err;
});

/plugins/socketIO/index.js

exports.register = function(server, options, next) {
    var io = require('socket.io').listen(server.select('chat').listener,{log:false});
    io.sockets.on('connection', function (socket) {
        socket.on('someAction', function(name, cb) {
           ...
        });
        ...     
   });
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4