RangeError:超出最大调用堆栈大小。谁能帮我?

时间:2018-05-01 18:11:51

标签: node.js socket.io

我有一个"输入类型的文字"和一个选择。选择的选项是:比如,低语,大喊。我想为文本示例着色:如果selection.value是"说"那么颜色就是红色。这是我的代码:

<script src="/socket.io/socket.io.js"></script>
<script>

    let akarmi = undefined;

    var socket = io.connect('http://192.168.0.113:3000');
    const input = document.getElementById('inp');
    const button = document.getElementById('sub');
    const container = document.createElement("div");

    input.id = "messeage-input";
    button.id = "messeage-send";
    container.id = "messeage-container";

    document.body.appendChild(input);
    document.body.appendChild(button);
    document.body.appendChild(container);

    socket.on("message", function (data) {
        const value  = document.getElementById("select").value;
        const span = document.createElement("span");
        console.log(data.type)
        const text_node = document.createTextNode(data.ip.substring(17, 20) + ": [" + data.type + "]: " + data.message);

        if (value == "whisp") {
            //span.style.backgroundColor = "rgb(60,60,70)";
            span.style.color = "rgb(120,60,120)";
        }

        if (value == "yell") {
            //span.style.backgroundColor = "rgb(60,70,60)";
            span.style.color = "rgb(60,180,120)";
        }

        if (value == "say") {
            //span.style.backgroundColor = "rgb(70,60,60)";
            span.style.color = "rgb(120,60,60)";
        }

        span.appendChild(text_node);
        container.appendChild(span);
        container.appendChild(document.createElement("br"));

        console.log((performance.now() - akarmi)/1000);

        console.log("asdas");

    });

    button.onclick = function (event) {

        socket.emit("message", {message: input.value});
        socket.emit("type", {type: document.getElementById("select").value});
        input.value = "";
        console.log("lefut");   
        akarmi = performance.now();
    }

</script>

并且在server.js中我无法定义data.type:

io.on('connect', function(socket){

  socket.on("message", function (data) {
  data.ip = socket.handshake.address;
  data.type = socket.on("type", function (data){
    io.emit('type', data)
    console.log(data)
  });
  io.emit("message", data);
  });
}); 

然后返回Error:RangeError:超出最大调用堆栈大小

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

每当收到消息事件时,您都会发出消息事件。将df = pd.DataFrame({'Title': ['A', 'A', 'B', 'B', 'B', 'C'], 'Version': [1, 1, 1, 2, 3, 4], 'Board': ['S1', 'S2', 'S1', 'S2', 'S4', 'S1']}, columns=['Title', 'Version', 'Board']) print(df) # Title Version Board # 0 A 1 S1 # 1 A 1 S2 # 2 B 1 S1 # 3 B 2 S2 # 4 B 3 S4 # 5 C 4 S1 print(df.groupby(['Title']).agg(lambda x: ','.join(sorted(set(map(str, x))))).reset_index()) # Title Version Board # 0 A 1 S1,S2 # 1 B 1,2,3 S1,S2,S4 # 2 C 4 S1 事件更改为messageserverMessage

这样服务器代码将如下所示:

clientMessage

也需要在客户端进行类似的更改。