create the wsServer based on webserver, no need for a seperate wsPort

This commit is contained in:
砚然
2018-01-28 13:51:36 +08:00
parent c2760e0bb0
commit 5412a70627
15 changed files with 270 additions and 348 deletions

View File

@@ -19,7 +19,6 @@ import {
toggleRemoteGlobalProxyFlag,
updateShouldClearRecord,
updateIsRootCAExists,
updateGlobalWsPort,
showFilter,
updateLocalAppVersion
} from 'action/globalStatusAction';
@@ -141,14 +140,12 @@ class HeaderMenu extends React.Component {
ruleSummary: response.ruleSummary,
rootCADirPath: response.rootCADirPath,
ipAddress: response.ipAddress,
port: response.port,
wsPort: response.wsPort
port: response.port
});
this.props.dispatch(updateLocalInterceptHttpsFlag(response.currentInterceptFlag));
this.props.dispatch(updateLocalGlobalProxyFlag(response.currentGlobalProxyFlag));
this.props.dispatch(updateLocalAppVersion(response.appVersion));
this.props.dispatch(updateIsRootCAExists(response.rootCAExists));
this.props.dispatch(updateGlobalWsPort(response.wsPort));
})
.catch((error) => {
console.error(error);

View File

@@ -66,7 +66,7 @@ class RecordDetail extends React.Component {
getWsMessageDiv(recordDetail) {
const { globalStatus } = this.props;
return <RecordWsMessageDetail recordDetail={recordDetail} wsPort={globalStatus.wsPort} />;
return <RecordWsMessageDetail recordDetail={recordDetail} />;
}
getRecordContentDiv(recordDetail = {}, fetchingRecord) {

View File

@@ -49,8 +49,7 @@ class RecordWsMessageDetail extends React.Component {
}
static propTypes = {
recordDetail: PropTypes.object,
wsPort: PropTypes.number
recordDetail: PropTypes.object
}
toggleRefresh () {
@@ -112,13 +111,11 @@ class RecordWsMessageDetail extends React.Component {
}
componentDidMount () {
const { wsPort, recordDetail } = this.props;
if (!wsPort) {
return;
}
const { recordDetail } = this.props;
this.refreshPage();
this.wsClient = initWs(wsPort);
this.wsClient = initWs();
this.wsClient.addEventListener('message', this.onMessageHandler);
}

View File

@@ -140,12 +140,11 @@ class WsListener extends React.Component {
}
initWs() {
const { wsPort } = this.props.globalStatus;
if (!wsPort || this.state.wsInited) {
if (this.state.wsInited) {
return;
}
this.state.wsInited = true;
const wsClient = initWs(wsPort);
const wsClient = initWs();
wsClient.onmessage = this.onWsMessage;
}