Add support for and use socket host override. (#1682)

* Add support for and use socket host override. Closes #1378

* Fix embeds with the new websocket constructor
This commit is contained in:
Gabe Kangas
2022-03-06 17:11:51 -08:00
committed by GitHub
parent 9d5bdc320c
commit d24ddc2b0a
9 changed files with 75 additions and 82 deletions

View File

@@ -20,6 +20,7 @@ import {
URL_CONFIG,
TIMER_STATUS_UPDATE,
} from './utils/constants.js';
import { URL_WEBSOCKET } from './utils/constants.js';
export default class StandaloneChat extends Component {
constructor(props, context) {
@@ -53,6 +54,8 @@ export default class StandaloneChat extends Component {
this.setupChatAuth = this.setupChatAuth.bind(this);
this.disableChat = this.disableChat.bind(this);
this.socketHostOverride = null;
// user events
this.handleWebsocketMessage = this.handleWebsocketMessage.bind(this);
@@ -98,7 +101,7 @@ export default class StandaloneChat extends Component {
}
setConfigData(data = {}) {
const { chatDisabled } = data;
const { chatDisabled, socketHostOverride } = data;
// If this is the first time setting the config
// then setup chat if it's enabled.
@@ -107,7 +110,7 @@ export default class StandaloneChat extends Component {
}
this.hasConfiguredChat = true;
this.socketHostOverride = socketHostOverride;
this.setState({
canChat: !chatDisabled,
configData: {
@@ -277,7 +280,10 @@ export default class StandaloneChat extends Component {
}
// Without a valid access token he websocket connection will be rejected.
const websocket = new Websocket(accessToken);
const websocket = new Websocket(
accessToken,
this.socketHostOverride || URL_WEBSOCKET
);
websocket.addListener(
CALLBACKS.RAW_WEBSOCKET_MESSAGE_RECEIVED,
this.handleWebsocketMessage