Prepare to join servers

This commit is contained in:
Maciej 2026-02-28 16:19:35 +02:00
parent 3afaf346c7
commit 984ac15084
Signed by: maciej
GPG key ID: 28243AF437E32F99
12 changed files with 137 additions and 17 deletions

View file

@ -24,6 +24,13 @@ defmodule BirdyChatWeb.ServerChannel do
end
end
# This is how we send messages
def broadcast!(peer, message) do
channel = "server:#{peer}"
encoded_message = :erlang.term_to_binary(message)
BirdyChatWeb.Endpoint.broadcast!(channel, "new_message", {:binary, encoded_message})
end
# Simple token-based authentication. Servers should use the same Phoenix secret key so they will
# have the basis for generating tokens.
defp authorised?(%{"token" => token}, server_id) do