Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express')
  2. const http = require('http')
  3. const socketIO = require('socket.io')
  4.  
  5. // our localhost port
  6. const port = 9000
  7.  
  8. const app = express()
  9.  
  10. // our server instance
  11. const server = http.createServer(app)
  12.  
  13. // This creates our socket using the instance of the server
  14. const io = socketIO(server)
  15.  
  16. // This is what the socket.io syntax is like, we will work this later
  17. io.on('connection', socket => {
  18.   console.log('User connected')
  19.  
  20.   socket.on('disconnect', () => {
  21.     console.log('user disconnected')
  22.   })
  23. })
  24.  
  25. server.listen(port, () => console.log(`Listening on port ${port}`))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement