aboutsummaryrefslogtreecommitdiff
path: root/client/src/Client.elm
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-07-30 14:43:25 +0200
committerJasper Van der Jeugt2020-07-30 14:43:25 +0200
commit4e1068c41b84f0813b82fe61816271b92ca76f48 (patch)
treea0d0c0c612157a93b5c6548d61cd8103544facf3 /client/src/Client.elm
parent724d731227294f0b2975d66ed727aca3f89c30ab (diff)
Basic syncing
Diffstat (limited to '')
-rw-r--r--client/src/Client.elm14
1 files changed, 13 insertions, 1 deletions
diff --git a/client/src/Client.elm b/client/src/Client.elm
index 0644a12..442f089 100644
--- a/client/src/Client.elm
+++ b/client/src/Client.elm
@@ -3,7 +3,7 @@ port module Client exposing (main)
import Browser
import Html exposing (Html)
import Json.Decode
-import Messages
+import Messages exposing (GameView)
import Url exposing (Url)
port webSocketIn : (String -> msg) -> Sub msg
@@ -19,6 +19,9 @@ type Model
| Connecting
{ roomId : String
}
+ | Game
+ { view : GameView
+ }
parseRoomId : Url -> Result String String
parseRoomId url = case String.split "/" url.path of
@@ -35,6 +38,13 @@ view model = case model of
[ Html.h1 []
[Html.text <| "Connecting to room " ++ state.roomId ++ "..."]
]
+ Game game ->
+ [ Html.h1 [] [Html.text "Players"]
+ , Html.ul [] <| List.map
+ (\p -> Html.li [] [Html.text p])
+ game.view.players
+ ]
+
subscriptions : Model -> Sub Msg
subscriptions model = webSocketIn WebSocketIn
@@ -49,6 +59,8 @@ update msg model = case msg of
Ok (Messages.Welcome playerId) ->
Debug.log ("Welcome " ++ String.fromInt playerId) (model, Cmd.none)
Ok Messages.Bye -> Debug.log "Bye" (model, Cmd.none)
+ Ok (Messages.SyncGameView gameView) ->
+ (Game {view = gameView}, Cmd.none)
main : Program () Model Msg
main = Browser.application