Skip to content
This repository was archived by the owner on Mar 6, 2020. It is now read-only.

Commit 5b886ae

Browse files
committed
socket-events: use RCS plugSock reference if available
1 parent c1b5adf commit 5b886ae

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/plugins/SocketEventsPlugin.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,21 @@ function sudo(cb) {
3939
}
4040

4141
function getSocket() {
42+
// If RCS is loaded and already has a reference to the WebSocket, just use
43+
// that.
44+
if (window.rcs && window.rcs.plugSock &&
45+
window.rcs.plugSock.sock instanceof WebSocket) {
46+
return window.rcs.plugSock.sock;
47+
}
48+
4249
const send = WebSocket.prototype.send;
4350
let socket;
4451
WebSocket.prototype.send = function sendIntercept(data) {
45-
if (data.indexOf(CHAT_INTERCEPT_STRING)) {
52+
if (this.url.indexOf('plug.dj') !== -1 && data.indexOf(CHAT_INTERCEPT_STRING) !== -1) {
4653
socket = this;
4754
WebSocket.prototype.send = send;
55+
} else {
56+
send.call(this, data);
4857
}
4958
};
5059
sudo(() => {

0 commit comments

Comments
 (0)