読者です 読者をやめる 読者になる 読者になる

Socket.IO やってみた

JavaScript
const Http      = require( 'http' );
const Express   = require( 'express' );
const Socket_IO = require( 'socket.io' );

const app = Express();

const server = Http.createServer( app );

const io = Socket_IO( server );

const port = 3000;

app.get( '/', (request, response) => {
    response.sendFile( __dirname + '/client/index.html' );
} );

server.listen( port, () => {
    console.log( 'server listening at port %d', port );
} );

io.on( 'connection', socket => {
    console.log( 'a user connected' );

    socket.on( 'chat message', message => {
        console.log( `message: ${message}` );
    } )

    socket.on( 'disconnect', () => {
        console.log( 'user disconnected' );
    } );
} );

a user connected が表示されない………。
\(^o^)/オワタ

const server = require( 'http' ).createServer();

と:

const Http = require( 'http' )

const server = Http.createServer();

は一緒のはずだよね???