Forum C# Question about Timer operation on multiplayer room

Question about Timer operation on multiplayer room

Postby HVStudios » October 22nd, 2013, 2:36 am

Hi, how are you?

I have the following questions on Timer operation on multiplayer room.

1. If all the players are disconnected from a room where a timer is scheduled, is the room going to be destroyed at the moment when the last player is disconnected? Or is it still alive since it has the running timer?

2. In that case, is the timer going to be triggered on the scheduled time even after all the players are disconnected?

3. If another player joins to the server (maybe to the same room type but different instance), is it possible to cancel or reschedule that already existing timer scheduled from previous room?

4. If all the timers will be destroyed when the room where those timers were scheduled is destroyed, then is there any way to keep the room alive even after all the players are disconnected? I mean, if there is a way to define a dummy player and make it always be connected, it can be a solution. Would you please let me know if it is possible in the Player.IO framework?


Thank you very much in advance and I will looking forward to hearing back from you. Have a nice day.


Best Regards,

Tae Joon Park from Hidden Variable Studios.
HVStudios
Paid Member
 
Posts: 20
Joined: July 30th, 2013, 7:15 pm

Re: Question about Timer operation on multiplayer room

Postby Benjaminsen » October 22nd, 2013, 5:19 pm

HVStudios wrote:Hi, how are you?

I have the following questions on Timer operation on multiplayer room.

1. If all the players are disconnected from a room where a timer is scheduled, is the room going to be destroyed at the moment when the last player is disconnected? Or is it still alive since it has the running timer?



We do not guarantee code execution after last leave. E.g. it might execute once, it might not.

HVStudios wrote:2. In that case, is the timer going to be triggered on the scheduled time even after all the players are disconnected?


Maybe?

HVStudios wrote:3. If another player joins to the server (maybe to the same room type but different instance), is it possible to cancel or reschedule that already existing timer scheduled from previous room?


No, make sure that your timer does not run if there is no-one connected.

HVStudios wrote:4. If all the timers will be destroyed when the room where those timers were scheduled is destroyed, then is there any way to keep the room alive even after all the players are disconnected? I mean, if there is a way to define a dummy player and make it always be connected, it can be a solution. Would you please let me know if it is possible in the Player.IO framework?


Absolutely not, relying on live room is bad game design. Rather you should serialize your state to BigDB and load it on reboot of your game.

HVStudios wrote:Thank you very much in advance and I will looking forward to hearing back from you. Have a nice day.


Best Regards,

Tae Joon Park from Hidden Variable Studios.


- Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Question about Timer operation on multiplayer room

Postby HVStudios » October 22nd, 2013, 7:03 pm

Then, please let me know your opinion on the following idea.

- Whenever it is necessary to schedule a timer, instead of instantiating the 'Timer' object, save necessary information into the BigDB (maybe the time when the timer scheduled or the time when a specific event should be happen).

- Implement and construct a system that can connect to the server periodically.

- When connecting with the server, make the system check the saved information on BigDB and perform a specific operation or trigger an event if the timer condition is satisfied.


If it is a feasible approach, I would like to ask one more thing. Is it possible to make a Player.IO client as a .Net stand alone client, compile it using Mono, and run it on Linux machine?
HVStudios
Paid Member
 
Posts: 20
Joined: July 30th, 2013, 7:15 pm

Re: Question about Timer operation on multiplayer room

Postby Benjaminsen » October 24th, 2013, 3:55 pm

You can totally do that, however could you explain to me under what scenario you would need something like that?
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Question about Timer operation on multiplayer room

Postby HVStudios » October 24th, 2013, 7:26 pm

We are developing a turn based board game. We are utilizing the push notification to inform one player's move to the opponent player.

If the opponent player does not make any move within pre-defined time period, the game will be expired and the opponent player will lose the game. So, we are sending additional warning push notification to the opponent player just couple of hours before the game expiration if he/she does not make any move.

So the system flow would be something like the follows:

- Player1 connects to the server.
- Player1 makes move
- System sends a push notification to player2.
- System schedules a warning push notification to player 2. (Currently, three days after the move)
- Player1 leaves from the server.



- Player2 connects to the server.
- Player2 makes move
- System sends a push notification to player1.
- System cancels the notification scheduled for player2.
- System schedules a warning push notification to player 1. (Currently, three days after the move)
- Player1 leaves from the server.


We are using another middleware solution for push notification. Currently, to send or schedule a push notification, the PlayerIO server sends a web Post request to our web server, and our web server translates it as a JSON format POST request and then sends to the push notification middleware server. For the scheduled notification, our web server returns to the PlayerIO server the notification ID of the scheduled notification returned from the push notification middleware, so that PlayerIO server can cancel it later. If the opponent player does not make any move, the scheduled notification will be delivered. If the opponent player makes move, the PlayerIO server will send push canceling request using the ID.



But it seems that the scheduling and more specifically the canceling operation are not that much stable and robust, so currently our testers are receiving a lot of wrong expiration warning notifications. So my plan is, instead of using the push scheduling and canceling, to make a special client that can ping the server game data periodically and send push notification request whenever necessary.
HVStudios
Paid Member
 
Posts: 20
Joined: July 30th, 2013, 7:15 pm

Re: Question about Timer operation on multiplayer room

Postby Benjaminsen » October 25th, 2013, 8:44 pm

HVStudios wrote:We are developing a turn based board game. We are utilizing the push notification to inform one player's move to the opponent player.

If the opponent player does not make any move within pre-defined time period, the game will be expired and the opponent player will lose the game. So, we are sending additional warning push notification to the opponent player just couple of hours before the game expiration if he/she does not make any move.

So the system flow would be something like the follows:

- Player1 connects to the server.
- Player1 makes move
- System sends a push notification to player2.
- System schedules a warning push notification to player 2. (Currently, three days after the move)
- Player1 leaves from the server.



- Player2 connects to the server.
- Player2 makes move
- System sends a push notification to player1.
- System cancels the notification scheduled for player2.
- System schedules a warning push notification to player 1. (Currently, three days after the move)
- Player1 leaves from the server.


We are using another middleware solution for push notification. Currently, to send or schedule a push notification, the PlayerIO server sends a web Post request to our web server, and our web server translates it as a JSON format POST request and then sends to the push notification middleware server. For the scheduled notification, our web server returns to the PlayerIO server the notification ID of the scheduled notification returned from the push notification middleware, so that PlayerIO server can cancel it later. If the opponent player does not make any move, the scheduled notification will be delivered. If the opponent player makes move, the PlayerIO server will send push canceling request using the ID.



But it seems that the scheduling and more specifically the canceling operation are not that much stable and robust, so currently our testers are receiving a lot of wrong expiration warning notifications. So my plan is, instead of using the push scheduling and canceling, to make a special client that can ping the server game data periodically and send push notification request whenever necessary.


Oki, that is actually the one case we do not currently support nicely. Using a scheduler here is perfectly acceptable.
I suggest you setup a cron job that connects via the .NET API to see game status in BigDB.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Question about Timer operation on multiplayer room

Postby HVStudios » October 25th, 2013, 9:13 pm

Yes, that is my current plan. Setup a Linux server with Mono, and setup a crontab job to run it periodically. Or setup a Windows system with .Net and set it up to run the client periodically using the task scheduler or any other crontab clone for Windows. (I tested the .Net client on Ubuntu with Mono but the network connection was not stable. 2 of 10 tries were failed to get connected while it was working perfectly on Windows.)
HVStudios
Paid Member
 
Posts: 20
Joined: July 30th, 2013, 7:15 pm

Re: Question about Timer operation on multiplayer room

Postby Benjaminsen » October 25th, 2013, 11:53 pm

HVStudios wrote:Yes, that is my current plan. Setup a Linux server with Mono, and setup a crontab job to run it periodically. Or setup a Windows system with .Net and set it up to run the client periodically using the task scheduler or any other crontab clone for Windows. (I tested the .Net client on Ubuntu with Mono but the network connection was not stable. 2 of 10 tries were failed to get connected while it was working perfectly on Windows.)


Mono really does not like the asynch sockets that we use in the .NET framework. I highly recommend that you use a windows box.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Question about Timer operation on multiplayer room

Postby HVStudios » October 28th, 2013, 11:15 pm

Even the Connect function should be called at the beginning of the communication does not return the value from time to time. I am using the synchronous version that is not passing those two delegate functions to get the result or error as parameters. Is it also something related with the difference on the synch sockets you mentioned?
HVStudios
Paid Member
 
Posts: 20
Joined: July 30th, 2013, 7:15 pm


Return to C#