not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
783 B

  1. const io = require('socket.io-client');
  2. const rel = require('readline');
  3. const url = 'http://129.21.91.149:3000';
  4. var rl = rel.createInterface({
  5. input: process.stdin,
  6. output: process.stdout,
  7. terminal: false
  8. });
  9. var socket = io.connect(url);
  10. rl.on('line', function(line){
  11. var event = line.substring(0,line.indexOf(' '));
  12. var msg = line.substring(line.indexOf(' ') + 1);
  13. switch(event){
  14. case 'joinRoom':
  15. case 'createRoom':
  16. msg = JSON.parse(msg);
  17. case 'register':
  18. case 'submitWord':
  19. case 'updateRoom':
  20. socket.emit(event, msg);
  21. }
  22. });
  23. var print = function(data){
  24. console.log(data);
  25. };
  26. socket.on('sendRooms', print);
  27. socket.on('updateRoom', print);
  28. socket.on('registerFailed', print);
  29. socket.on('joinFailed', print);