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 // Incoming room events
channel.on("vote", app.ports.gotVote.send) channel.on("vote", app.ports.gotVote.send)
channel.on("reset", app.ports.gotReset.send) channel.on("reset", app.ports.gotReset.send)
channel.on("reveal", app.ports.gotReveal.send)
// Outgoing room events // Outgoing room events
app.ports.roomActions.subscribe(action => { app.ports.roomActions.subscribe(action => {

View file

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

View file

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

View file

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