socket.io通信

socket.ionpm install 

 
socket = require('socket.io-client')(ProAddress + '/test');
socket.on('exp_output', function (res: any) {
console.log("==========後臺返回的結果", res)
if (res.type == 'result_back') { // 結果返回
that.setState({
isShowResult: true,
});
that.renderResult(res.data.drawType, res.data.drawData);
} else if (res.type == 'user_vars') { // 變量
that.setState({
variableData: res.data
});
} else if (res.type == 'stdout_msg') { // 打印錯誤信息
that.setState({
codeErrorInfo: res.data[0]
});
} else if (res.type == 'step_done') { // 是否結束
that.setState({
loading: false
});
}

});

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章