mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
Send ClientHello response to ServerHello
This commit is contained in:
parent
8af797a04c
commit
e9159a432b
@ -43,7 +43,7 @@ proto.addType('FML|HS',
|
|||||||
|
|
||||||
// ServerHello
|
// ServerHello
|
||||||
{
|
{
|
||||||
"name": "fmlProtocolVersion",
|
"name": "fmlProtocolVersionServer",
|
||||||
"type": [
|
"type": [
|
||||||
"switch",
|
"switch",
|
||||||
{
|
{
|
||||||
@ -82,7 +82,7 @@ proto.addType('FML|HS',
|
|||||||
|
|
||||||
// ClientHello
|
// ClientHello
|
||||||
{
|
{
|
||||||
"name": "fmlProtocolVersion",
|
"name": "fmlProtocolVersionClient", // TODO: merge or fix name collision with fmlProtocolVersionServer?
|
||||||
"type": [
|
"type": [
|
||||||
"switch",
|
"switch",
|
||||||
{
|
{
|
||||||
@ -110,5 +110,22 @@ client.on('custom_payload', function(packet) {
|
|||||||
} else if (channel === 'FML|HS') {
|
} else if (channel === 'FML|HS') {
|
||||||
var parsed = proto.parsePacketBuffer('FML|HS', data);
|
var parsed = proto.parsePacketBuffer('FML|HS', data);
|
||||||
console.log('FML|HS',parsed);
|
console.log('FML|HS',parsed);
|
||||||
|
|
||||||
|
|
||||||
|
if (parsed.data.discriminator === 0) { // ServerHello
|
||||||
|
if (parsed.data.fmlProtocolVersionServer > 2) {
|
||||||
|
// TODO: support higher protocols, if they change
|
||||||
|
}
|
||||||
|
|
||||||
|
var clientHello = proto.createPacketBuffer('FML|HS', {
|
||||||
|
discriminator: 1, // ClientHello
|
||||||
|
fmlProtocolVersionClient: parsed.data.fmlProtocolVersionServer
|
||||||
|
});
|
||||||
|
|
||||||
|
client.write('custom_payload', {
|
||||||
|
channel: 'FML|HS',
|
||||||
|
data: clientHello
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user