ClockworkPirate
ClockworkPirate
NNormal
Created by ClockworkPirate on 10/4/2024 in #🤝ask-a-question
DidRead method never called in Model
I can see my FireEvent being called on Client 1, but then the DidRead never gets called on the other clients. As a secondary question, should I expect DidRead to also get called on the Client that called FireEvent? Here's my code:
using Normal.Realtime;

[RealtimeModel]
public partial class BasketModel {
[RealtimeProperty(1, true)] private int _trigger;
[RealtimeProperty(2, true)] private int _senderID;

// Used to fire an event on all clients
public void FireEvent(int senderID) {
this.trigger++;
this.senderID = senderID;
}

// An event that consumers of this model can subscribe to in order to respond to the event
public delegate void EventHandler(int senderID);
public event EventHandler eventDidFire;

// A RealtimeCallback method that fires whenever we read any values from the server
[RealtimeCallback(RealtimeModelEvent.OnDidRead)]
private void DidRead()
{
UnityEngine.Debug.LogError("DidRead called");

if (eventDidFire != null && trigger != 0)
eventDidFire(senderID);
}
}
using Normal.Realtime;

[RealtimeModel]
public partial class BasketModel {
[RealtimeProperty(1, true)] private int _trigger;
[RealtimeProperty(2, true)] private int _senderID;

// Used to fire an event on all clients
public void FireEvent(int senderID) {
this.trigger++;
this.senderID = senderID;
}

// An event that consumers of this model can subscribe to in order to respond to the event
public delegate void EventHandler(int senderID);
public event EventHandler eventDidFire;

// A RealtimeCallback method that fires whenever we read any values from the server
[RealtimeCallback(RealtimeModelEvent.OnDidRead)]
private void DidRead()
{
UnityEngine.Debug.LogError("DidRead called");

if (eventDidFire != null && trigger != 0)
eventDidFire(senderID);
}
}
17 replies