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
});
}
});