How do I receive a broadcast when another tab is opened

Get help using Construct 2

Post » Thu May 05, 2016 9:43 pm

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!
B
3
Posts: 3
Reputation: 179

Post » Thu May 05, 2016 10:53 pm

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.
Mistakes were made.
B
52
S
26
G
111
Posts: 1,623
Reputation: 62,667

Post » Fri May 06, 2016 1:12 pm

oosyrag wrote:https://www.dropbox.com/s/sjtjilffjvtdu5a/MP-ChangeLayout.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.


Thanks for the example, now I know where the problem is! :D
B
3
Posts: 3
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: Jackriduk, kiki4construct, osek95 and 17 guests