node.js - 发出套接字时出错:内部/引导程序/pre_execution.js:308
问题描述
internal/bootstrap/pre_execution.js:308
get() {
^
RangeError: Maximum call stack size exceeded
at get (internal/bootstrap/pre_execution.js:308:8)
at hasBinary (/home/spirit/Documents/ProjectsJS/ProjectBack/node_modules/has-binary2/index.js:44:3)
您好,我正在尝试发出我的套接字,但出现此错误,并且我无法在我使用的所有代码下方的后端接收我的套接字
io.on('connection', function (socket) {
setInterval(() => Queue.searching() , 1000);
sessionMap.set(socket.id,socket);
//ADD PLAYER TO QUEUE
socket.on('addPlayer-Queue', (result) => {
const player = {
id:result.id,
socketid: socket.id,
name: result.name,
mmr: result.mmr,
socket: socket
}
const nPlayer = new Player(player);
Queue.addPlayer(nPlayer);
/*
console.log(queue);
console.log(sessionMap.all());*/
//socket.emit('match', matches)
});
});
//
searching = () => {
const firstPlayer = this.getRandomPlayer();
const secondPlayer = this.players.find(
playerTwo =>
playerTwo.mmr < this.calculateLessThanPercentage(firstPlayer) &&
playerTwo.mmr > this.calculateGreaterThanPercentage(firstPlayer) &&
playerTwo.id != firstPlayer.id
);
if(secondPlayer){
const matchedPlayers = [firstPlayer, secondPlayer];
this.removePlayers(matchedPlayers);
Matches.configurePlayersForNewMatch(matchedPlayers);
}
}
//
getMatchConfigurationFor = players => {
console.log(sessionMap.all())
if(players){
const match = new Match(players);
const result = {
idMatch: match.id,
playerOne: match.players[0],
playerTwo:match.players[1]
}
return result;
}
}
configurePlayersForNewMatch = (matchedPlayers) => {
matchedPlayers.forEach(player =>
sessionMap.get(player.socketId)
.broadcast.to(player.socketId)
.emit('match',
this.getMatchConfigurationFor(matchedPlayers)));
}
所以我承认问题出在这段代码片段中:
matchedPlayers.forEach(player =>
sessionMap.get(player.socketId)
.broadcast.to(player.socketId)
.emit('match',
this.getMatchConfigurationFor(matchedPlayers)));
会话映射是我的套接字保存密钥(套接字 ID)和稍后通过发射发送的套接字的映射。关于我的 session.map 的控制台日志,这是控制台。登录我的套接字播放器https://pastebin.com/XHDXH9ih
解决方案
推荐阅读
- c - 从 MPI_Recv 中的特定位置开始存储值
- php - 多个客户端可以同时接收从一个唯一 php 发送的相同数据(使用 AJAX)吗?
- python - BigQuery 执行时间
- flask - socket.io 客户端无法捕获来自 flask-socketio 服务器的事件
- pdf - iText7 - 打印时创建具有精确尺寸的 PDF - 如何?
- python - 为什么我的递归函数展开并返回第一个分数而不是最后一个分数?
- javascript - 在异步等待函数中抛出错误并从调用它的位置捕获
- javascript - 尝试导入错误:“formatDate”未从“src/utils”导出
- linux - linux korn shell /../.envfile [a]..[b]..[c] 含义
- c# - C#中的IText 7锁定坏pdf