My problem is that always when I check via socket if player is online in node.js, I get 0x00 byte as a response. I tried with many different IP adresses. My question is how to send message with player name to get correct response. My code(but I don't expect you to fix my code, just looking for a suggestion):
So, as you see I'm sending 0xFF, 0x01, 0x40(and of course, when my buffer is complete I put length of full message at the beginning, this works because other requests are working) and then sending player name in ASCII encoding. I've also tried putting name length as uint16(little-endian) before string but with no success. I always get 0x00 - offline. Please help me.
Code:
this.getPlayerInfo = function(name) {
var sendBuffer = new MsgBuffer(new Buffer([0xFF, 0x01, 0x40]));
sendBuffer.putString(name, 'ASCII');
var communication = new Communication(host, port);
communication.on('connected', function () {
communication.send(sendBuffer.getBuffer(true));
})
communication.on('receivedBytes', function(bytes) {
console.log('Received: ' + bytes.length);
if(bytes[2] == 0x22)
console.log('0x22! : REQUEST_PLAYER_STATUS_INFO');
if(bytes[3] == 0x01)
console.log('online?');
else if(bytes[3] == 0x00)
console.log('offline?');
});
communication.connect();
}