Skip to content

Commit

Permalink
start the bots
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienVesper committed May 23, 2021
1 parent eb42789 commit c385d0b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ typings/

# TypeScript build
build/

# Original script from moddio/loadtest
bot.js
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
},
"dependencies": {
"@clusterws/cws": "^3.0.0",
"lz-string": "^1.4.4",
"ws": "^7.4.5"
}
}
11 changes: 11 additions & 0 deletions src/bot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import config from './config';
import { WebSocket } from '@clusterws/cws';

const createBot = () => {
const ws = new WebSocket(`ws://${config.ip}:${config.port}`, `netio1`);
ws.on(`open`, (connection: WebSocket) => {

});
};

export default createBot;
9 changes: 6 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ import { hideBin } from 'yargs/helpers';

interface Args {
ip: string,
port: number
port: number,
maxBots: number
}

const argv = yargs(hideBin(process.argv)).options({
ip: { type: `string`, default: `127.0.0.1` },
port: { type: `number`, default: 2000 }
port: { type: `number`, default: 2000 },
maxBots: { type: `number`, default: 1 }
}).argv;

const config = {
name,
version,

ip: (argv as Args).ip,
port: (argv as Args).port
port: (argv as Args).port,
maxBots: (argv as Args).maxBots
};

export default config;
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import config from './config';
import log from './utils/log';
import logSplash from './utils/logSplash';

import createBot from './bot';

logSplash();

log(`green`, `Connecting to ${config.ip}:${config.port}...`);

for (let i = 0; i < config.maxBots; i++) createBot();

log(`yellow`, `Bot creation complete. Press ^C to exit.`);
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,11 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

lz-string@^1.4.4:
version "1.4.4"
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26"
integrity sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=

merge2@^1.3.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
Expand Down

0 comments on commit c385d0b

Please sign in to comment.