Skip to content

Commit

Permalink
Connect options are added:
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeka0 committed Nov 15, 2019
1 parent 1738eaf commit eed4023
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 12 deletions.
127 changes: 125 additions & 2 deletions client.js
@@ -1,6 +1,17 @@
var io = require('socket.io-client');
// https://hazel-form-257916.appspot.com
var socket = io.connect('https://hazel-form-257916.appspot.com',
{
reconnectionDelay: 1000,
reconnection:true,
reconnectionAttempts: 10,
transports: ['websocket'],
agent: false, // [2] Please don't set this to true
upgrade: false,
rejectUnauthorized: false

var socket = io.connect('https://hazel-form-257916.appspot.com/', {reconnect: true});
}
);

const readline = require('readline').createInterface({
input: process.stdin,
Expand All @@ -16,8 +27,120 @@ socket.emit('createGame', { name: "deka" });

socket.on('newGame', (data) => {
console.log(data);
readline.question(`What's your name?`, (name) => {
readline.question(`Waiting for user input:`, (name) => {
console.log(`Hi ${name}!`)
readline.close()
})
});


socket.on('popup', function(msg){
console.log("hello: ", msg)
});
socket.on('connection', function() {
console.log("client connected");
});

socket.on('connect_error', function(err) {
console.log("client connect_error: ", err);
});

socket.on('connect_timeout', function(err) {
console.log("client connect_timeout: ", err);
});

/**
* A simple socket.io client for performance benchmark
*
* Created by redism on 2014. 4. 22..
*/

// var SocketIO = require('socket.io-client');

// var n = 10;
// var b = 10; // bucket-size
// var host = 'https://hazel-form-257916.appspot.com/';
// var sockets = [];

// var msg = 1;

// var connectionCount = 0;
// var disconnectionCount = 0;
// var reconn = 0;

// var setupSocket = function setupSocket(socket, id) {
// socket.data = {id: id};
// socket.on('connect', function () {
// connectionCount++;
// });

// socket.on('disconnect', function () {
// connectionCount--;
// disconnectionCount++;
// });

// socket.on('reconnect', function () {
// reconn++;
// });

// socket.on('error', function (err) {
// console.log('Error:', err);
// })


// socket.on('echo', function (msg) {
// console.log(this.data.id, 'received', msg);
// });
// }

// var startTest = function startTest() {
// setInterval(function () {
// // emit message once per second for each socket.
// var i, socket;
// for (i = 0; i < sockets.length; i++) {
// socket = sockets[i];
// socket.emit('joinGame', { name:"deka", room:"room-1" });
// }

// // Monitor count
// console.log('Connection count:', connectionCount, 'dis:', disconnectionCount, 're:', reconn);
// }, 1000);
// }


// var socket, i;

// var remaining = n * b;
// var socketsToConnect = 0;

// var tryMoreConnection = function tryMoreConnection() {
// // If all previous connections have been established,
// if (socketsToConnect == connectionCount) {
// // try another bucket size
// for (i = 0; i < b; i++) {
// (function (j) {
// socket = SocketIO.connect(host, {
// secure: true,
// reconnection: true,
// rejectUnauthorized: false
// });
// setupSocket(socket, j);
// sockets.push(socket);
// socketsToConnect++;
// remaining--;
// })(i);
// }
// }

// // Check if we have more clients to simulate.
// if (remaining > 0) {
// setTimeout(function () {
// tryMoreConnection();
// }, 100);
// }
// }

// tryMoreConnection();

// console.log('Starting stress test client, host :', host + ', socket # :', n);
// startTest();
28 changes: 18 additions & 10 deletions test.yml
@@ -1,26 +1,34 @@
config:
#target: https://hazel-form-257916.appspot.com/
target: http://localhost:8080/
target: https://hazel-form-257916.appspot.com/
socketio:
transports: ["websocket"]
reconnectionDelay: 1000
reconnection: true
reconnectionAttempts: 10
agent: false
upgrade: false
rejectUnauthorized: false
#target: http://localhost:8080/
phases:
- duration: 2
arrivalRate: 1
- duration: 1000
arrivalRate: 10
scenarios:
- name: "Connect and send a bunch of messages"
- name: "Load Test"
engine: "socketio"
flow:
#- loop:
- emit:
# channel: "createGame"
# data: {name: deka}
channel: "joinGame"
data: { name: "deka1", room: "room-1"}
response:
channel: "player2"
data: {name: deka1, room: 'room-1'}
data: { name: "deka1", room: "room-2"}
# response:
# channel: "player2"
# data: {name: deka1, room: 'room-1'}

# capture:
# regexp: "deka"
# as: "id"
# log: "Id value: {{ id }}"
#- think: 0
- think: 1
#count: 50

0 comments on commit eed4023

Please sign in to comment.