Skip to content

Going further: set up a private chat between users #83

Description

@ndrean

image

Question: How do you create a private chat between two users?

I did not find a way to get all subscribers.

When you look at the code for Phoenix.PubSub.subscribe:

# Phoenix.PubSub.subscribe
def subscribe(pubsub, topic, opts \\ [])
      when is_atom(pubsub) and is_binary(topic) and is_list(opts) do
   case Registry.register(pubsub, topic, opts[:metadata]) do
  {:ok, _} -> :ok

# Phoenix.PubSub.unsubscribe
def unsubscribe(pubsub, topic) when is_atom(pubsub) and is_binary(topic) do
  Registry.unregister(pubsub, topic)

Dwyl/I use Phoenix.Endpoint instead of Phoenix.PubSub and the PubSub is started with:

{Phoenix.PubSub, name: MyApp.PubSub},

and the standard configuration is:

config :live_map, MyAppWeb.Endpoint,
  pubsub_server: MyApp.PubSub,

We don't use the "atom" form" . Does this start a registry?

I don't see anything:

iex> Registry.count(MyAppPubSub)
# 12 ????
iex> Registry.keys(MyApp.PubSub, self())
# []  ?????

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions