Skip to content

Send modern/Netty ping? 1.7+ status handshake ping #7

@deathcap

Description

@deathcap

The FE01 ping although called a "legacy" ping is supported on 1.4.4+ onwards, including 1.5.2, 1.6.4, and the Netty-based (protocol rewrite) Minecraft server versions 1.7.10, 1.8.9, and 1.9 snapshots — nonetheless, there is a new ping using the new Netty-ish protocol, involving some complicated encoding and STATUS handshake with a set_protocol packet.

Should node-minecraft-ping support this ping? It is already implemented and works well in https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/ping.js

  client.once('server_info', function(packet) {
    var data = JSON.parse(packet.response);
    var start = Date.now();
    client.once('ping', function(packet) {
      data.latency = Date.now() - start;
      cb(null, data);
      client.end();
    });
    client.write('ping', {time: [0, 0]});
  });

  client.on('state', function(newState) {
    if(newState === states.STATUS)
      client.write('ping_start', {});
  });

  client.on('connect', function() {
    client.write('set_protocol', {
      protocolVersion: options.protocolVersion,
      serverHost: options.host,
      serverPort: options.port,
      nextState: 1
    });
    client.state = states.STATUS;
  });

users can just use node-minecraft-protocol instead, perhaps node-minecraft-ping could use it via node-minecraft-protocol, but this adds another dependency (for clients which will likely already have their own node-minecraft-protocol direct dependency). Not clear if it is worth it, or even worth supporting this so-called modern ping altogether. At least for what I'm interested in (https://github.com/deathcap/node-minecraft-protocol-auto automatic protocol negotiation), FE01 ping does everything I want and more.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions