Skip to content

Commit

Permalink
Working websocket client support
Browse files Browse the repository at this point in the history
  • Loading branch information
deathcap committed Jun 23, 2014
1 parent 6c9d53d commit 3f0c7e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,18 @@ var decodePacket = function(data) {

Bot.prototype.connect = function(options) {
var self = this;

var ws = websocket_stream(options.url, {type: Uint8Array});
self.client = this;
self.username = options.username;
ws.write(self.username);
ws.on('data', function(data) {
var packet = decodePacket(data);

// TODO
console.log('packet=',packet);
self.client = mc.createClient(options);
self.username = self.client.username;
self.client.on('session', function() {
self.username = self.client.username;
});
ws.on('connect', function() {
self.client.on('connect', function() {
self.emit('connect');
});
ws.on('error', function(err) {
self.client.on('error', function(err) {
self.emit('error', err);
});
ws.on('close', function() {
self.client.on('end', function() {
self.emit('end');
});
for (var pluginName in plugins) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"browser": "browser.js",
"dependencies": {
"requireindex": "~1.0.0",
"minecraft-protocol": "git+https://github.com/andrewrk/node-minecraft-protocol.git#master",
"minecraft-protocol": "git+https://github.com/deathcap/node-minecraft-protocol.git#e93ea9baaf39472c42fe2ae8734eed30f863dd04",
"quotemeta": "0.0.0",
"vec3": "~0.1.3",
"lodash": "^2.4.1",
Expand Down

0 comments on commit 3f0c7e8

Please sign in to comment.