11defmodule PointingPartyWeb.RoomChannel do
22 use PointingPartyWeb , :channel
3+
34 alias PointingParty.Card
5+
46 def join ( "room:lobby" , _payload , socket ) do
57 send ( self ( ) , :after_join )
68
@@ -9,29 +11,34 @@ defmodule PointingPartyWeb.RoomChannel do
911
1012 def handle_info ( :after_join , socket ) do
1113 # handle Presence listing and tracking here
14+
1215 { :noreply , socket }
1316 end
1417
1518 def handle_in ( "user_estimated" , % { "points" => points } , socket ) do
1619 # update votes for user presence
1720 # calculate votes if everyone voted with the help of the VoteCalculator
1821 # broadcast the 'winner'/'tie' event with a payload of %{points: points}
22+
1923 { :noreply , socket }
2024 end
2125
2226 def handle_in ( "finalized_points" , % { "points" => points } , socket ) do
2327 # update state by setting the current card to the next card
2428 # broadcast the "new_card" message with a payload of %{card: new_current_card}
29+
2530 { :reply , :ok , socket }
2631 end
2732
2833 def handle_in ( "start_pointing" , _params , socket ) do
2934 updated_socket = initialize_state ( socket )
3035 # broadcast the "new_card" message with a payload of %{card: current_card}
36+
3137 { :reply , :ok , updated_socket }
3238 end
3339
3440 defp initialize_state ( % { assigns: % { cards: _cards } } = socket ) , do: socket
41+
3542 defp initialize_state ( socket ) do
3643 [ first | cards ] = Card . cards ( )
3744
0 commit comments