Skip to content

Commit

Permalink
Server can trigger blueprint updates on all connected clients
Browse files Browse the repository at this point in the history
  • Loading branch information
thommcgrath committed Jun 6, 2024
1 parent 148d50d commit 2570664
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Project/App.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ Implements NotificationKit.Receiver,Beacon.Application
Self.mPusher = New Beacon.PusherSocket
If (Self.mIdentityManager Is Nil) = False And Self.mIdentityManager.CurrentUserId.IsEmpty = False Then
Self.mPusher.Start()
Self.SubscribeToPusherPublic()
End If
Self.NextLaunchQueueTask
End Sub
Expand Down Expand Up @@ -1424,6 +1425,7 @@ Implements NotificationKit.Receiver,Beacon.Application
Var UserId As String = Self.mIdentityManager.CurrentUserId
If UserId.IsEmpty = False Then
Self.mPusher.Start()
Self.SubscribeToPusherPublic()
Var UserChannelName As String = Beacon.PusherSocket.UserChannelName(UserId)
Self.mPusher.Listen(UserChannelName, "user-updated", AddressOf Pusher_UserUpdated)
Self.mPusher.Listen(UserChannelName, "cloud-updated", AddressOf Pusher_CloudUpdated)
Expand Down Expand Up @@ -1544,6 +1546,16 @@ Implements NotificationKit.Receiver,Beacon.Application
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub Pusher_UpdateBlueprints(ChannelName As String, EventName As String, Payload As String)
#Pragma Unused ChannelName
#Pragma Unused EventName
#Pragma Unused Payload

Self.SyncGamedata(True, False)
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub Pusher_UserUpdated(ChannelName As String, EventName As String, Payload As String)
#Pragma Unused ChannelName
Expand Down Expand Up @@ -1646,6 +1658,13 @@ Implements NotificationKit.Receiver,Beacon.Application
End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub SubscribeToPusherPublic()
Self.mPusher.Subscribe("beacon-public")
Self.mPusher.Listen("beacon-public", "update-blueprints", AddressOf Pusher_UpdateBlueprints)
End Sub
#tag EndMethod

#tag Method, Flags = &h0
Sub SyncGamedata(Silent As Boolean, ForceRefresh As Boolean)
If Silent Then
Expand Down

0 comments on commit 2570664

Please sign in to comment.