Emit reveal command across the network

This commit is contained in:
Correl Roush 2020-05-14 22:18:38 -04:00
parent 7fb7cc4805
commit 086ebb3da5
4 changed files with 17 additions and 1 deletions

View file

@ -51,6 +51,7 @@ app.ports.joinRoom.subscribe(options => {
// Incoming room events
channel.on("vote", app.ports.gotVote.send)
channel.on("reset", app.ports.gotReset.send)
channel.on("reveal", app.ports.gotReveal.send)
// Outgoing room events
app.ports.roomActions.subscribe(action => {

View file

@ -1,6 +1,7 @@
port module PlanningPokerAPI exposing
( gotPresence
, gotReset
, gotReveal
, gotVote
, joinRoom
, newProfile
@ -78,4 +79,7 @@ port gotPresence : (Decode.Value -> msg) -> Sub msg
port gotVote : (Decode.Value -> msg) -> Sub msg
port gotReveal : (Decode.Value -> msg) -> Sub msg
port gotReset : (Decode.Value -> msg) -> Sub msg

View file

@ -43,6 +43,7 @@ type Msg
| JoinRoom
| GotPresence Decode.Value
| GotVote Decode.Value
| GotReveal
| GotReset
@ -120,7 +121,7 @@ update key msg model =
)
Reveal ->
( { model | showVotes = True }
( model
, API.reveal
)
@ -166,6 +167,11 @@ update key msg model =
_ ->
( model, Cmd.none )
GotReveal ->
( { model | showVotes = True }
, Cmd.none
)
GotReset ->
let
newPlayers =
@ -381,6 +387,7 @@ subscriptions =
Sub.batch
[ API.gotPresence GotPresence
, API.gotReset (\_ -> GotReset)
, API.gotReveal (\_ -> GotReveal)
, API.gotVote GotVote
]

View file

@ -42,6 +42,10 @@ defmodule PlanningpokerWeb.RoomChannel do
broadcast!(socket, "reset", %{})
{:noreply, socket}
end
def handle_in("reveal", _, socket) do
broadcast!(socket, "reveal", %{})
{:noreply, socket}
end
def handle_in(_event, _data, socket) do
{:noreply, socket}
end