Connect to a certain game instead of index.

This commit is contained in:
Danila Fedorin 2018-05-25 13:02:50 -07:00
parent e56560bcce
commit b0c9c5ec18
2 changed files with 5 additions and 2 deletions

2
Go.elm
View File

@ -44,6 +44,6 @@ update msg model = case msg of
subscriptions : Model -> Sub Msg subscriptions : Model -> Sub Msg
subscriptions m = subscriptions m =
WebSocket.listen m.sessionUrl Update WebSocket.listen (wsUrl m) Update
main = Html.programWithFlags { init = init, update = update, subscriptions = subscriptions, view = view } main = Html.programWithFlags { init = init, update = update, subscriptions = subscriptions, view = view }

View File

@ -2,6 +2,9 @@ module Go.Ws exposing (..)
import Go.Types exposing (..) import Go.Types exposing (..)
import WebSocket import WebSocket
wsUrl : Model -> String
wsUrl m = (m.sessionUrl ++ "/game/" ++ (toString m.sessionId))
encodeCell : Cell -> String encodeCell : Cell -> String
encodeCell ((x, y), c) = "place " encodeCell ((x, y), c) = "place "
++ (toString x) ++ " " ++ (toString x) ++ " "
@ -9,4 +12,4 @@ encodeCell ((x, y), c) = "place "
++ (toString c) ++ (toString c)
sendMove : Model -> Cell -> Cmd Msg sendMove : Model -> Cell -> Cmd Msg
sendMove m c = WebSocket.send m.sessionUrl (encodeCell c) sendMove m c = WebSocket.send (wsUrl m) (encodeCell c)