Prepare to join servers
This commit is contained in:
parent
3afaf346c7
commit
984ac15084
12 changed files with 137 additions and 17 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue