question

Patrick Kenny avatar image
Patrick Kenny asked

Keep time of day for servers

Hi, i have several rooms (servers) that need to have their own time of day, so when someone logs in it can set the time of day to that time. I would need a way to keep that time and update it for the client to read. (also its possible to have several instances of a room, so having the room keep the time won't work.) What is the best way to do this. There would need to be a function that updates the time and ways for all clients and the server to read that data. ,Hi, i have several rooms (servers) that need to have their own time of day, so when someone logs in it can set the time of day to that time. I would need a way to keep that time and update it for the client to read. (also its possible to have several instances of a room, so having the room keep the time won't work.) What is the best way to do this. There would need to be a function that updates the time and ways for all clients and the server to read that data.

CloudScriptTitle DataCustom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

If you mean each server has its own time of day and this time is not related to real world time. A simple approach is to have the server maintain its own time of day after startup and leave it open to other services.

If I misunderstood your question, please explain more about your scenario.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Patrick Kenny avatar image Patrick Kenny commented ·

Let me give a better example. I will spawn 3 rooms of the same type, e.g. New York. Then another 2 rooms, e.g. Paris. I want the New York rooms to all have the same time (That increments like a Time of Day), and Paris different time. When someone logs into, say NY, it should be whatever time NY is set to (regardless of which room instance they are in.) If someone else logs into NY, it should be the same as the other person in that room. If I bring one of the rooms down and back up, they should load the current Time of Day for that room. So somewhere on Playfab, or a cloud script I need to have something that updates a timer, that the servers can all read. Now if I have 40 rooms, then I would need a dictionary or something that updates all the rooms. (Let’s assume all the times increment at the same rate.) The players could read the time from the servers, but the servers would need to read from Playfab.

0 Likes 0 ·
Neils Shi avatar image Neils Shi Patrick Kenny commented ·

The servers don’t need to read time from PlayFab. You can implement a function in server which can convert the timestamp to the time of New York or Paris after server obtains the current timestamp, then client can obtain the time via server. Or the server can pass the current timestamp directly to the client, and then clients can convert the time locally according to the room region.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.