(userMessageName: string)
| 1449 | }; |
| 1450 | |
| 1451 | const hasCustomMessageBeenReceived = (userMessageName: string) => { |
| 1452 | const customMessageName = |
| 1453 | getCustomMessageNameFromUserMessageName(userMessageName); |
| 1454 | const p2pMessagesMap = gdjs.multiplayerPeerJsHelper.getAllMessagesMap(); |
| 1455 | const messagesList = p2pMessagesMap.get(customMessageName); |
| 1456 | if (!messagesList) return; // No message received. |
| 1457 | const messages = messagesList.getMessages(); |
| 1458 | if (!messages.length) return; // No messages to process. |
| 1459 | |
| 1460 | debugLogger.info(`custom message ${userMessageName} has been received.`); |
| 1461 | |
| 1462 | let customMessageHasNotAlreadyBeenProcessed = false; |
| 1463 | |
| 1464 | messages.forEach((message) => { |
| 1465 | const messageData = message.getData(); |
| 1466 | const uniqueMessageId = messageData.uniqueId; |
| 1467 | const customMessageCacheKey = `${customMessageName}#${uniqueMessageId}`; |
| 1468 | if (processedCustomMessagesCache.has(customMessageCacheKey)) { |
| 1469 | // Message has already been processed recently. This can happen if the message is sent multiple times, |
| 1470 | // after not being acknowledged properly. |
| 1471 | return; |
| 1472 | } |
| 1473 | processedCustomMessagesCache.add(customMessageCacheKey); |
| 1474 | |
| 1475 | customMessageHasNotAlreadyBeenProcessed = true; |
| 1476 | return; |
| 1477 | }); |
| 1478 | |
| 1479 | return customMessageHasNotAlreadyBeenProcessed; |
| 1480 | }; |
| 1481 | |
| 1482 | const getCustomMessageData = (userMessageName: string) => { |
| 1483 | const customMessageName = |
nothing calls this directly
no test coverage detected