Cleanup and reorganise some shard stuff

This commit is contained in:
Schuyler Cebulskie
2016-09-27 02:25:38 -04:00
parent e5a987e0ef
commit 9d3b7b49dd
4 changed files with 65 additions and 65 deletions

View File

@@ -55,21 +55,21 @@ class ShardingManager extends EventEmitter {
this.on('message', (shard, message) => {
if (!message) return;
if (message._sEval) {
this.broadcastEval(message._sEval)
.then(results => shard.send({ _sEval: message._sEval, _result: results }))
.catch(err => shard.send({ _sEval: message._sEval, _error: err }));
} else if (message._sFetchProp) {
if (message._sFetchProp) {
this.fetchClientValues(message._sFetchProp)
.then(results => shard.send({ _sFetchProp: message._sFetchProp, _result: results }))
.catch(err => shard.send({ _sFetchProp: message._sFetchProp, _error: err }));
} else if (message._sEval) {
this.broadcastEval(message._sEval)
.then(results => shard.send({ _sEval: message._sEval, _result: results }))
.catch(err => shard.send({ _sEval: message._sEval, _error: err }));
}
});
}
/**
* Spawns a single shard.
* @param {number} id The ID of the shard to spawn. THIS IS NOT NEEDED IN ANY NORMAL CASE!
* @param {number} id The ID of the shard to spawn. **This is usually not necessary.**
* @returns {Promise<Shard>}
*/
createShard(id = this.shards.size) {