How do I receive a broadcast when another tab is opened

0 favourites
  • 3 posts
  • Hey guys,

    I started creating a game with multiplayer and got into a little problem.

    I made a game where peers listen for a broadcast, when they receive it, they go to another layout. (This can be done with multiple layouts) I tested this myself with different tabs in my browser and realised when I do the broadcast twice (or more) with the host (so the peers should change layout twice), the peers don't seem to change their layout. Are they not receiving the broadcast from the host because their tab isn't open or active? And is there any way to fix this problem?

    I know it's just a detail and will not happen a lot with actual players but this project is for school and my teacher is one of the kind that loves digging into code to find bugs...

    Thanks in advance!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • https://www.dropbox.com/s/sjtjilffjvtdu ... .capx?dl=0

    They do receive the broadcast, but they do not run until you focus the tab again.

    Try downloading the example capx, preview, duplicating a few tabs. On the host tab, click anywhere to send the message to change layouts.

    On peers, they will receive the message, wait 3, then change layouts.

    You can switch to each tab to see that they all got the message to change layouts, but don't start their 3 second delay until the tab is active.

    In the event where your layouts have different event sheets, or when you send multiple messages in the same frame (before going back to the peer tab to process the original message), you may end up with issues.

  • dropbox.com/s/sjtjilffjvtdu5a/MP-ChangeLayout.capx

    They do receive the broadcast, but they do not run until you focus the tab again.

    Try downloading the example capx, preview, duplicating a few tabs. On the host tab, click anywhere to send the message to change layouts.

    On peers, they will receive the message, wait 3, then change layouts.

    You can switch to each tab to see that they all got the message to change layouts, but don't start their 3 second delay until the tab is active.

    In the event where your layouts have different event sheets, or when you send multiple messages in the same frame (before going back to the peer tab to process the original message), you may end up with issues.

    Thanks for the example, now I know where the problem is!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)