Fixed voice_connection.stopPlaying

Now unpipes before destroying
This commit is contained in:
Amish Shah
2015-12-26 17:52:20 +00:00
parent a6a9f08565
commit 0113202c2f
10 changed files with 37 additions and 29 deletions

View File

@@ -182,6 +182,7 @@ var Server = (function (_Equality) {
this.eventStopSpeaking(user);
channel.speaking.add(user);
user.voiceChannel = channel;
return true;
} else {
// bad
@@ -206,6 +207,7 @@ var Server = (function (_Equality) {
if (chan.speaking.has(user)) {
chan.speaking.remove(user);
user.voiceChannel = null;
return chan;
}
}

View File

@@ -36,6 +36,7 @@ var User = (function (_Equality) {
since: null,
channel: null
};
this.voiceChannel = null;
}
User.prototype.mention = function mention() {

View File

@@ -102,12 +102,10 @@ var AudioEncoder = (function () {
});
enc.stdout.on("end", function () {
console.log("end");
reject("end");
});
enc.stdout.on("close", function () {
console.log("close");
reject("close");
});
});
@@ -129,12 +127,10 @@ var AudioEncoder = (function () {
});
enc.stdout.on("end", function () {
console.log("end");
reject("end");
});
enc.stdout.on("close", function () {
console.log("close");
reject("close");
});
});

View File

@@ -43,6 +43,10 @@ var _events = require("events");
var _events2 = _interopRequireDefault(_events);
var _unpipe = require("unpipe");
var _unpipe2 = _interopRequireDefault(_unpipe);
var VoiceConnection = (function (_EventEmitter) {
_inherits(VoiceConnection, _EventEmitter);
@@ -91,13 +95,10 @@ var VoiceConnection = (function (_EventEmitter) {
VoiceConnection.prototype.stopPlaying = function stopPlaying() {
this.playing = false;
this.playingIntent = null;
if (this.streamProc) {
this.streamProc.stdin.pause();
this.streamProc.kill("SIGINT");
}
if (this.instream) {
//not all streams implement these...
//and even file stream don't seem to implement them properly...
_unpipe2["default"](this.instream);
if (this.instream.end) {
this.instream.end();
}
@@ -106,6 +107,11 @@ var VoiceConnection = (function (_EventEmitter) {
}
this.instream = null;
}
if (this.streamProc) {
this.streamProc.stdin.pause();
this.streamProc.kill("SIGINT");
this.streamProc = null;
}
};
VoiceConnection.prototype.playStream = function playStream(stream) {
@@ -118,9 +124,6 @@ var VoiceConnection = (function (_EventEmitter) {
var length = 20;
if (self.playingIntent) {
self.stopPlaying();
}
self.playing = true;
var retStream = new _StreamIntent2["default"]();
var onWarning = false;
@@ -318,7 +321,6 @@ var VoiceConnection = (function (_EventEmitter) {
var _this4 = this;
var self = this;
console.log("\n\nendpoint:", this.endpoint, "\n\n");
_dns2["default"].lookup(this.endpoint, function (err, address, family) {
var vWS = self.vWS = new _ws2["default"]("wss://" + _this4.endpoint, null, { rejectUnauthorized: false });
_this4.endpoint = address;