-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlocalRun.js
More file actions
31 lines (25 loc) · 726 Bytes
/
localRun.js
File metadata and controls
31 lines (25 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const WebSocket = require('ws');
const faker = require("faker");
const { v4: uuidv4 } = require('uuid');
const url = 'ws://127.0.0.1:8999'; // SERVER ADDRESS
function runTest() {
const connection = new WebSocket(url);
const player = {
id: uuidv4(),
rankedLevel: Math.floor(Math.random() * 100),
name: faker.name.firstName()
};
connection.onopen = () => {
connection.send(JSON.stringify(player));
};
connection.onerror = error => {
console.log(error);
};
connection.onmessage = e => {
console.log(e.data);
};
connection.onclose = () => {
console.log('connection closed by host.');
};
}
setInterval(() => runTest(), 500);