how to handle code server side
how do i run a timer for example on the server and get a signal sent to all the clients when that timer reaches 0
realtime.room.time is a synchronized clock that matches the room server's clock exactly with no added latency. You can start the stopwatch by calling StartStopwatch(), and you can get the elapsed time by accessing the time property.time is 0 in your game loop, and if it is, you can trigger whatever event you want.ownerID of -1, which denotes that it has no owner. When a model is unowned, it can be modified by anyone in the room. However, when a model is owned by a client, the server only lets the owning client make changes to it or to any of its child models.roomModel that's passed to Room.Connect(). Any models that are not part of realtime components that you would like to store in the datastore need to be a child of this model.realtime.room.timeStartStopwatch()ownerID-1roomModelRoom.Connect()using Normal.Realtime;
public class Stopwatch : RealtimeComponent<StopwatchModel> {
public float time {
get {
// Return 0 if we're not connected to the room yet.
if (model == null) return 0.0f;
// Make sure the stopwatch is running
if (model.startTime == 0.0) return 0.0f;
// Calculate how much time has passed
return (float)(realtime.room.time - model.startTime);
}
}
public void StartStopwatch() {
model.startTime = realtime.room.time;
}
}