Socket.IO やってみた
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();
は一緒のはずだよね???