Guest User

Untitled

a guest
Apr 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. var socket = io.connect();
  2.  
  3. socket.on('connect', function () {
  4. alert('Socket is connected.');
  5. });
  6.  
  7. socket.on('disconnect', function () {
  8. alert('Socket is disconnected.');
  9. });
  10.  
  11. var socket = io.connect('http://<ip>:<port>', {
  12. reconnection: false
  13. });
  14. socket.on('connect_error', function() {
  15. console.log('Failed to connect to server');
  16. });
  17.  
  18. var socket;
  19. try {
  20. socket = io();
  21. }
  22. catch() {
  23. window.location = "nodeServerDown.php";
  24. }
Add Comment
Please, Sign In to add comment