Skip to content

Commit

Permalink
Add internal client monitoring (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko authored Mar 27, 2024
1 parent b730990 commit 6425e2f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/kino/bridge.ex
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@ defmodule Kino.Bridge do
with {:ok, reply} <- io_request(:livebook_get_tmp_dir), do: reply
end

@doc """
Starts monitoring clients presence from the given process.
The monitoring process receives the following messages:
* `{:client_join, client_id}`
* `{:client_leave, client_id}`
When the monitor starts and there are already clients that joined,
the join message is going to be delivered for each of them right
away.
"""
@spec monitor_clients(pid()) :: :ok | {:error, request_error()}
def monitor_clients(pid) do
with {:ok, reply} <- io_request({:livebook_monitor_clients, pid}), do: reply
end

@doc """
Checks if the caller is running within Livebook context (group leader).
"""
Expand Down

0 comments on commit 6425e2f

Please sign in to comment.