Skip to content

Commit

Permalink
Add workerstream stub
Browse files Browse the repository at this point in the history
  • Loading branch information
deathcap committed Mar 25, 2015
1 parent 8573d71 commit d8c6680
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions clientmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var websocket_stream = require('websocket-stream');
var ever = require('ever');
var tellraw2dom = require('tellraw2dom');
var webworkify = require('webworkify');
var workerstream = require('workerstream');
var vec3Object = require('vec3'); // note: object type used by mineflayer, NOT gl-vec3 which is just a typed array :(

module.exports = function(game, opts) {
Expand Down Expand Up @@ -238,6 +239,13 @@ ClientMC.prototype.enable = function() {
username = hash.substring(1); // remove #
}

this.mfworker = webworkify(require('./mf-worker.js'));
this.mfworkerStream = workerstream(this.mfworker);
this.mfworkerStream.write('test');
this.mfworkerStream.on('data', function(data) {
console.log('mfworkerStream data',data);
});

// create bot
this.bot = mineflayer.createBot({
username: username,
Expand Down
11 changes: 11 additions & 0 deletions mf-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

var ParentStream = require('workerstream/parent');

module.exports = function(self) {
self.onmessage = function(event) {
console.log('mf-worker onmessage',event);
self.postMessage({whats: 'up'});
};
};

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"tellraw2dom": "0.0.4",
"vec3": "^0.1.3",
"websocket-stream": "^1.4.0",
"webworkify": "~0.1.0",
"webworkify": "^1.0.2",
"workerstream": "^1.2.1",
"wsmc": "git://github.com/deathcap/wsmc.git#master"
},
"scripts": {
Expand Down

0 comments on commit d8c6680

Please sign in to comment.