Multiplayer Event: on message arrived

Discussion and feedback on Construct 2

Post » Mon Mar 24, 2014 3:15 pm

Hello fellas,

@Ashley

I think this kind of event is missing: "OnMessageArrived", which will be especially useful for turn based games, at least the host should know about that.

Example:
- 2 Players are playing a card game against each other with limited time for a turn
- 1st Player's turn: the host is sending a message telling him it is his turn
- Message has arrived to the peer, host starts the timer
- and so on

Right now I can only do it by sending a message back from the peer to the host, telling that it has arrived, which is kind of waste of events and may be creates some delay.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Mon Mar 24, 2014 3:21 pm

@xoros

Agree. I had made a plugin for chat by wrap some multi-player event into my plugin, which hidden the host/peer into plugin, so that user could ignore the concept of host/peer.
I am thinking about a turned based plugin recently, it also sent command through message channel.
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Mon Mar 24, 2014 3:35 pm

Interesting. I think structuring the multiplayer project into host, peer and common is a good idea and if you want to make it more user friendly the concepts of host/peer should still be present "under the hood" in order that game works properly. In your plugin, which I used a lot it was called Room Moderator.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Mon Mar 24, 2014 3:46 pm

Another thing, is it possible to sync the game state (variables and objects) not 30 times per second, but with an action only once, under some desired condition? Now this is possible with messages and some work arounds, but it would be definitely very convenient to be able to that.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Mon Mar 24, 2014 4:00 pm

I don't understand: you already have "On peer message". That should work for your purposes right?

Obviously it would be wasteful if the multiplayer engine sent unchanging data 30 times a second. It doesn't do that. If the data is not changing, it gradually reduces the rate to 2 times per second. (This is still necessary so a newly joining peer gets the game data, or lost packets are eventually corrected.) It can also vary the transmission rate per-instance, so if you have 10 instances and only one is changing, it will send 1 instance 30 times a second and 9 instances 2 times a second. The bandwidth of 2 updates per second is probably negligible for all uses.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,772

Post » Mon Mar 24, 2014 6:16 pm

I'm not complaining or something. If the host has broadcast the message on peers, "on peer message" doesn't get triggered on the host (may be it shouldn't get triggered). That's why peers should send another message back to the host, saying that it received it, but it's ok.

IMHO the current architecture of multiplayer functionality is not optimal for turn based games. I made many of them and the way I got used to work is only possible with "SendMessage" right now - the way syncing functionality is implemented is just too much. For example, I have a text box which shows timer for the current turn, in order to sync the time variable I have to sync text object's position first, which is redundant.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 25, 2014 3:01 am

@xoros

Indeed, I had noticed that the peer could not received the message by itself.
The problem comes from the execution flow. In my concept, I split command execution into 2 stages,
Each of player (host/peer) will request a command, then go through validating, and executing stage,

1. validate stage: player check if this command could be run by call it's validating function. If not, do nothing, else (validating pass)
- host: broadcast this command to all peers, then go to stage2 immediately
- peer: send request to host, then go to stage2 immediately , so that there is no delay
------> when host receive request from peer, host will run the same validating function, it should be pass like sender-peer, otherwise the validating had mismatched, something wrong at this sender-peer. If the validating pass (match with sender-peer), broadcast this command to all peers. ( then go to stage2 immediately )

2. execute stage: execute command
- player(host/peer) who request the command and validating pass will go to this stage
- peers receive the command which validating by host will go to this stage


---
On the other word -
1. [peer] request a command
2. [peer] validate this command (could I run this command?)
3. [peer] if validated pass, execute this command and send this request to host

4. [host] receive command , then validate it
5. [host] if validated pass, execute this command and send this request to other peers
- if validated failed , something with that peer

6. [other peer] get validated command, execute it.
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Tue Mar 25, 2014 3:31 am

@xoros

The reason of no delay in ghost-shooter example is "predicting" -- character of peer will be moved immediately when key pressed. It predicted the position at local, and corrected at next sync from host.
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Tue Mar 25, 2014 9:05 am

@rexrainbow

The logic you described sounds very reasonable. Are you building something on top of the official multiplayer plugin or it will be your own implementation something like bottleneck?
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 25, 2014 9:22 am

@xoros

Actually the host/peer structure is the basic of all, but the problem is - it's too detail to build game by host/peer. Thinking about most of C2 users are not programming background, there is a mess in their event sheets, "evey tick" everywhere.

That's why I try to make a "framework" for turned base game.


The request-validate-execute sequence had be done in my plugin (WIP). I am think about how to get random number(shuffle cards or something else). The easier way is to sync the random seed to each player initially. They are all based on official multi-player plugin. (Ohya, I do not need node.js server at all ! )

BTW, "action: close room" might be necessary. For example, if the max peers is 4. The game start at 2 players, and it might want to close the room to reject others players.
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 31 guests