diff options
author | Jasper Van der Jeugt | 2020-07-30 14:43:25 +0200 |
---|---|---|
committer | Jasper Van der Jeugt | 2020-07-30 14:43:25 +0200 |
commit | 4e1068c41b84f0813b82fe61816271b92ca76f48 (patch) | |
tree | a0d0c0c612157a93b5c6548d61cd8103544facf3 /client/src/Client.elm | |
parent | 724d731227294f0b2975d66ed727aca3f89c30ab (diff) |
Basic syncing
Diffstat (limited to 'client/src/Client.elm')
-rw-r--r-- | client/src/Client.elm | 14 |
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 |