Created
          July 30, 2018 13:46 
        
      - 
      
- 
        Save claytonbez/6dabe6800e32cddbe7f9848d0e6c93cb to your computer and use it in GitHub Desktop. 
    socket-io-client starter
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var serverIndex = args.indexOf('--server') + 1; | |
| if (!serverIndex) { | |
| console.log('No port specified. use --port <portnumber> as arguments when starting this script'.red.bold); | |
| process.exit(); | |
| } | |
| var server = args[serverIndex]; | |
| var io = require('socket.io-client'); | |
| var socket = io.connect(server); | |
| socket.on('connect',function(){ | |
| console.log(`Connected to ${server}`); | |
| }); | |
| socket.on('disconnect',function(){ | |
| console.log(`${server} disconnected`); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment