3.1.1 • Published 4 months ago
@xmcl/client v3.1.1
Client Module
Minecraft socket pipeline utilities. Support Minecraft lan server discovery.
Usage
Ping Minecraft Server
Read sever info (server ip, port) and fetch its status (ping, server motd):
import { queryStatus, Status, QueryOptions } from '@xmcl/client'
const serverInfo = {
host: 'your host',
port: 25565, // be default
};
const options: QueryOptions = {
/**
* see http://wiki.vg/Protocol_version_numbers
*/
protocol: 203,
};
const rawStatusJson: Status = await fetchStatus(info, options);
Detect LAN Minecraft Server
You can detect if player share LAN server.
Or you can fake a LAN server.
import { MinecraftLanDiscover, LanServerInfo } from '@xmcl/client'
const discover = new MinecraftLanDiscover();
await discover.bind(); // start to listen any lan server
discover.on('discover', ({ motd, port }: LanServerInfo) => {
console.log(motd); // server motd
console.log(port); // server port
})
const isReady = discover.isReady // a boolean represent whether the discover is ready to use
// you can also fake a lan server
discover.broadcast({
motd: 'your motd',
port: 2384 // fake port
});
// fake LAN server is useful when you want to implement the P2P connection between two players
dicover.destroy(); // stop listening
3.1.1
4 months ago
3.0.2
7 months ago
3.1.0
6 months ago
3.0.1
1 year ago
3.0.0
1 year ago
2.1.3
2 years ago
2.1.2
2 years ago
2.1.1
3 years ago
2.1.0
3 years ago
2.0.6
4 years ago
2.0.5
4 years ago
2.0.4
4 years ago
2.0.3
4 years ago
2.0.2
4 years ago
2.0.1
4 years ago
2.0.1-alpha.1
4 years ago
2.0.1-alpha.0
4 years ago
2.0.0-alpha.0
4 years ago
1.0.2
4 years ago
1.0.3
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago