Skip to content

Commit

Permalink
run task on successful socket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushmau5 committed Mar 24, 2024
1 parent d4068a2 commit 4df09e6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/battleship_web/live/game_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,17 @@ defmodule BattleshipWeb.GameLive.Index do
if connected?(socket) do
BattleshipWeb.Endpoint.subscribe(@player_count_topic)
Presence.track(self(), @player_count_topic, socket.id, %{id: socket.id})
end

remote_node = TaskRunner.get_task_runner_node()
remote_node = TaskRunner.get_task_runner_node()

if remote_node != nil do
# Execute function on remote node
# This task updates the page view count
TaskRunner.run(
%{module: Accumulator.Tasks, function: :update_battleship_view_count, args: []},
remote_node
)
if remote_node != nil do
# Execute function on remote node
# This task updates the page view count
TaskRunner.run(
%{module: Accumulator.Tasks, function: :update_battleship_view_count, args: []},
remote_node
)
end
end

assign(socket, player_count: count)
Expand Down

0 comments on commit 4df09e6

Please sign in to comment.