This repository was archived by the owner on Aug 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
48 lines (40 loc) · 1.34 KB
/
Copy pathexample.js
File metadata and controls
48 lines (40 loc) · 1.34 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Recon Client - JavaScript (Node.js) Example
*
* Demonstrates how to use the Recon JavaScript client library
* to send commands to a Minecraft server via REST API.
*/
const Recon = require('./recon');
// Configuration
const host = '127.0.0.1';
const port = 4161;
const user = 'admin';
const password = 'your_password';
const timeout = 10000; // milliseconds
// Create client instance
const recon = new Recon(host, port, user, password, timeout);
(async () => {
// Test connection
console.log('Testing connection...');
let response = await recon.sendCommand('recon test', true);
if (response.success) {
console.log('Connection successful!');
console.log('Response:', response.response);
console.log('Plain Response:', response.plainResponse);
} else {
console.log('Connection failed!');
console.log('Error:', response.error);
}
console.log();
// Execute a command
const cmd = 'say Hello from Recon JavaScript client!';
console.log(`Executing command: ${cmd}`);
response = await recon.sendCommand(cmd, true);
if (response.success) {
console.log('Command executed successfully.');
console.log('Response:', response.response);
} else {
console.log('Command failed.');
console.log('Error:', response.error);
}
})();