Browse Source

added CLI client

master
ritfsaecdaq 6 years ago
parent
commit
722c2a84a0
2 changed files with 31 additions and 24 deletions
  1. +0
    -24
      googletrendsgame/server/test/serverTest.js
  2. +31
    -0
      googletrendsgame/server/test/userTester.js

+ 0
- 24
googletrendsgame/server/test/serverTest.js View File

@ -1,24 +0,0 @@
const io = require('socket.io-client');
const util= require('../utils');
const url = 'http://129.21.91.149:3000';
var sockets = [];
//sockets['yaboi1'] = io.connect(url);
//sockets['yaboi1'] = io.connect(url);
sockets[0]= io.connect(url);
sockets[0].emit('register', 'bigleaderman');
sockets[0].emit('createRoom', {password:'123', capacity:'4'});
for(var j = 0; j < 3; ++j){
sockets[j+1] = io.connect(url);
sockets[j+1].emit('register', 'UgandanKnuckles' + j);
sockets[j+1].emit('joinRoom', {roomName:'bigleaderman', password:'123'});
}
//for(var r = 0; r < 7; ++r){
//setTimeout(function(){
for(var u = 1; u <= 3; ++u){
sockets[u].emit('submitWord',util.getRandomWords(1)[0]);
}
// }, 5000);
//}

+ 31
- 0
googletrendsgame/server/test/userTester.js View File

@ -0,0 +1,31 @@
const io = require('socket.io-client');
const rel = require('readline');
const url = 'http://129.21.91.149:3000';
var rl = rel.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
var socket = io.connect(url);
rl.on('line', function(line){
var event = line.substring(0,line.indexOf(' '));
var msg = line.substring(line.indexOf(' ') + 1);
switch(event){
case 'joinRoom':
case 'createRoom':
msg = JSON.parse(msg);
case 'register':
case 'submitWord':
socket.emit(event, msg);
}
});
var print = function(data){
console.log(data);
};
socket.on('sendRooms', print);
socket.on('updateRoom', print);
socket.on('registerFailed', print);
socket.on('joinFailed', print);

Loading…
Cancel
Save