From e0e364c4f0cc50eccc744675cf938ff2578ed12e Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Fri, 25 Aug 2017 17:19:34 +0800 Subject: [PATCH] feat: add websocket --- .../Project/Interface/InterfaceList/Edit.js | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/client/containers/Project/Interface/InterfaceList/Edit.js b/client/containers/Project/Interface/InterfaceList/Edit.js index 4264de97..64d76ce3 100644 --- a/client/containers/Project/Interface/InterfaceList/Edit.js +++ b/client/containers/Project/Interface/InterfaceList/Edit.js @@ -61,27 +61,27 @@ class InterfaceEdit extends Component { } componentWillMount() { - // let domain = location.hostname + (location.port !== "" ? ":" + location.port : ""); - // let s = new WebSocket('ws://' + domain + '/api/interface/solve_conflict?id=' + this.props.match.params.actionId); - // s.onopen = () => { - // this.WebSocket = s; - // } + let domain = location.hostname + (location.port !== "" ? ":" + location.port : ""); + let s = new WebSocket('ws://' + domain + '/api/interface/solve_conflict?id=' + this.props.match.params.actionId); + s.onopen = () => { + this.WebSocket = s; + } - // s.onmessage = (e) => { - // let result = JSON.parse(e.data); - // if (result.errno === 0) { - // this.setState({ - // curdata: result.data, - // status: 1 - // }) - // } else { - // this.setState({ - // curdata: result.data, - // status: 2 - // }) - // } + s.onmessage = (e) => { + let result = JSON.parse(e.data); + if (result.errno === 0) { + this.setState({ + curdata: result.data, + status: 1 + }) + } else { + this.setState({ + curdata: result.data, + status: 2 + }) + } - // } + } }