deathcap / wsmc

WebSocket proxy to Minecraft
33 stars 10 forks source link

Move mineflayer-ws and minecraft-protocol-ws out of examples #15

Closed deathcap closed 9 years ago

deathcap commented 9 years ago

examples/mcwebchat/mineflayer-ws.js and minecraft-protocol-ws.js should be made available as part of wsmc public API, for use with other modules (https://github.com/deathcap/voxel-clientmc), not merely part of an example

deathcap commented 9 years ago

Moved mineflayer-ws but moving minecraft-protocol-ws for some reason causes it to crash, client.js:

  self.socket.on('data', function(data) {
    if (self.encryptionEnabled) data = new Buffer(self.decipher.update(data), 'binary');
    incomingBuffer = Buffer.concat([incomingBuffer, data]); // crashes here
    prepareParse()
  });

in Buffer.concat

  for (i = 0; i < list.length; i++) {
    var item = list[i]
    item.copy(buf, pos) // TypeError: undefined is not a function
    pos += item.length
  }

item is an ArrayBuffer, expected to a a Buffer (from https://www.npmjs.com/package/buffer) but it is not being augmented for some reason, even though it is when inside examples/mcwebchat.

deathcap commented 9 years ago

Caused by websocket-stream ^0.5.1 in wsmc vs ^1.4.0 in mcwebchat (has ArrayBuffer to Buffer constructor)