Skip to content

Commit

Permalink
add event for live config updates via sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
tudddorrr committed Jan 8, 2025
1 parent 11afe41 commit 7eaae83
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Packages/com.trytalo.talo/Runtime/APIs/GameConfigAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ namespace TaloGameServices
public class GameConfigAPI : BaseAPI
{
public event Action<LiveConfig> OnLiveConfigLoaded;
public event Action<LiveConfig> OnLiveConfigUpdated;

public GameConfigAPI() : base("v1/game-config") { }
public GameConfigAPI() : base("v1/game-config") {
Talo.Socket.OnMessageReceived += (response) => {
if (response.GetResponseType() == "v1.live-config.updated")
{
var data = response.GetData<GameConfigResponse>();
OnLiveConfigUpdated?.Invoke(new LiveConfig(data.config));
}
};
}

public async Task Get()
{
Expand Down

0 comments on commit 7eaae83

Please sign in to comment.