mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-04 21:11:04 -05:00
Send ClientHello response to ServerHello
This commit is contained in:
parent
8af797a04c
commit
e9159a432b
1 changed files with 19 additions and 2 deletions
|
@ -43,7 +43,7 @@ proto.addType('FML|HS',
|
|||
|
||||
// ServerHello
|
||||
{
|
||||
"name": "fmlProtocolVersion",
|
||||
"name": "fmlProtocolVersionServer",
|
||||
"type": [
|
||||
"switch",
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ proto.addType('FML|HS',
|
|||
|
||||
// ClientHello
|
||||
{
|
||||
"name": "fmlProtocolVersion",
|
||||
"name": "fmlProtocolVersionClient", // TODO: merge or fix name collision with fmlProtocolVersionServer?
|
||||
"type": [
|
||||
"switch",
|
||||
{
|
||||
|
@ -110,5 +110,22 @@ client.on('custom_payload', function(packet) {
|
|||
} else if (channel === 'FML|HS') {
|
||||
var parsed = proto.parsePacketBuffer('FML|HS', data);
|
||||
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…
Reference in a new issue