2018-05-25 10:40:35 -07:00
|
|
|
module Go.Ws exposing (..)
|
|
|
|
import Go.Types exposing (..)
|
|
|
|
import WebSocket
|
|
|
|
|
2018-05-25 13:02:50 -07:00
|
|
|
wsUrl : Model -> String
|
|
|
|
wsUrl m = (m.sessionUrl ++ "/game/" ++ (toString m.sessionId))
|
|
|
|
|
2018-05-25 10:40:35 -07:00
|
|
|
encodeCell : Cell -> String
|
|
|
|
encodeCell ((x, y), c) = "place "
|
|
|
|
++ (toString x) ++ " "
|
|
|
|
++ (toString y) ++ " "
|
|
|
|
++ (toString c)
|
|
|
|
|
|
|
|
sendMove : Model -> Cell -> Cmd Msg
|
2018-05-25 13:02:50 -07:00
|
|
|
sendMove m c = WebSocket.send (wsUrl m) (encodeCell c)
|