Move to fmlHandshakeStep()

This commit is contained in:
deathcap 2016-01-23 19:03:54 -08:00
parent 0b2550e206
commit 8fd30f6af9

View file

@ -200,20 +200,11 @@ function writeAck(client, phase) {
}); });
} }
client.on('custom_payload', function(packet) { function fmlHandshakeStep(client, data)
var channel = packet.channel; {
var data = packet.data;
if (channel === 'REGISTER') {
var channels = data.toString().split('\0');
console.log('Server-side registered channels:',channels);
// TODO: do something?
// expect: [ 'FML|HS', 'FML', 'FML|MP', 'FML', 'FORGE' ]
} 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 === 'ServerHello') { if (parsed.data.discriminator === 'ServerHello') {
if (parsed.data.fmlProtocolVersion > 2) { if (parsed.data.fmlProtocolVersion > 2) {
// TODO: support higher protocols, if they change // TODO: support higher protocols, if they change
@ -263,5 +254,18 @@ client.on('custom_payload', function(packet) {
console.log('HandshakeAck Complete!'); console.log('HandshakeAck Complete!');
} }
} }
}
client.on('custom_payload', function(packet) {
var channel = packet.channel;
var data = packet.data;
if (channel === 'REGISTER') {
var channels = data.toString().split('\0');
console.log('Server-side registered channels:',channels);
// TODO: do something?
// expect: [ 'FML|HS', 'FML', 'FML|MP', 'FML', 'FORGE' ]
} else if (channel === 'FML|HS') {
fmlHandshakeStep(client, data);
} }
}); });