MCPcopy
hub / github.com/4ian/GDevelop / hasCustomMessageBeenReceived

Function hasCustomMessageBeenReceived

Extensions/Multiplayer/messageManager.ts:1451–1480  ·  view source on GitHub ↗
(userMessageName: string)

Source from the content-addressed store, hash-verified

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 =

Callers

nothing calls this directly

Calls 8

infoMethod · 0.80
forEachMethod · 0.80
getMethod · 0.65
getMessagesMethod · 0.65
getDataMethod · 0.65
addMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected