mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
Minor fixes
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var WebSocket = require("ws");
|
||||
var dns = require("dns");
|
||||
var udp = require("dgram");
|
||||
@@ -13,11 +15,15 @@ var ffmpeg = require('fluent-ffmpeg');
|
||||
var AudioEncoder = require("./AudioEncoder.js");
|
||||
var VoicePacket = require("./VoicePacket.js");
|
||||
var StreamIntent = require("./StreamIntent.js");
|
||||
var EventEmitter = require("events");
|
||||
|
||||
var VoiceConnection = (function (_EventEmitter) {
|
||||
_inherits(VoiceConnection, _EventEmitter);
|
||||
|
||||
var VoiceConnection = (function () {
|
||||
function VoiceConnection(channel, client, session, token, server, endpoint) {
|
||||
_classCallCheck(this, VoiceConnection);
|
||||
|
||||
_EventEmitter.call(this);
|
||||
this.voiceChannel = channel;
|
||||
this.client = client;
|
||||
this.session = session;
|
||||
@@ -60,14 +66,12 @@ var VoiceConnection = (function () {
|
||||
self.playingIntent = retStream;
|
||||
|
||||
function send() {
|
||||
if (self.playingIntent && self.playingIntent !== retStream) {
|
||||
console.log("ending it!");
|
||||
if (!self.playingIntent) {
|
||||
self.setSpeaking(false);
|
||||
retStream.emit("end");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
var buffer = stream.read(1920);
|
||||
|
||||
if (!buffer) {
|
||||
@@ -147,7 +151,7 @@ var VoiceConnection = (function () {
|
||||
return self.sendPacket(packet, callback);
|
||||
} catch (e) {
|
||||
self.playing = false;
|
||||
console.log("etype", e.stack);
|
||||
self.emit("error", e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -216,7 +220,6 @@ var VoiceConnection = (function () {
|
||||
}
|
||||
}
|
||||
};
|
||||
console.log("success!!!");
|
||||
vWS.send(JSON.stringify(wsDiscPayload));
|
||||
firstPacket = false;
|
||||
}
|
||||
@@ -252,16 +255,14 @@ var VoiceConnection = (function () {
|
||||
var udpPacket = new Buffer(70);
|
||||
udpPacket.writeUIntBE(data.d.ssrc, 0, 4);
|
||||
udpClient.send(udpPacket, 0, udpPacket.length, data.d.port, self.endpoint, function (err) {
|
||||
console.log("err", err);
|
||||
if (err) self.emit("error", err);
|
||||
});
|
||||
break;
|
||||
case 4:
|
||||
|
||||
self.ready = true;
|
||||
self.mode = data.d.mode;
|
||||
console.log("ready!!!");
|
||||
|
||||
self.test();
|
||||
self.emit("ready", self);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -270,6 +271,6 @@ var VoiceConnection = (function () {
|
||||
};
|
||||
|
||||
return VoiceConnection;
|
||||
})();
|
||||
})(EventEmitter);
|
||||
|
||||
module.exports = VoiceConnection;
|
||||
Reference in New Issue
Block a user