| summaryrefslogtreecommitdiff |
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-09-27 15:40:30 +0200 |
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-09-27 15:40:30 +0200 |
| commit | 2f22e667fbea56884d74ed27777f2e9f3fc9fd53 (patch) | |
| tree | 75300c58cc7b287993887f84b2d68b9d515a9ec0 /src/Comm/Send.elm | |
| parent | 486ee1dbe21be962e89f421e1dd5f3cbb2fd2177 (diff) | |
Starting to separate background and popup code.
Diffstat (limited to 'src/Comm/Send.elm')
| -rw-r--r-- | src/Comm/Send.elm | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/Comm/Send.elm b/src/Comm/Send.elm deleted file mode 100644 index 3fc30ae..0000000 --- a/src/Comm/Send.elm +++ /dev/null @@ -1,66 +0,0 @@ -module Comm.Send exposing (try_sending) - --- Elm ------------------------------------------------------------------------- -import Http - -import Json.Decode -import Json.Encode - --- Extension ------------------------------------------------------------------- -import Comm.Okay -import Comm.SetBattles - -import Struct.Event -import Struct.ServerReply -import Struct.Model - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -internal_decoder : String -> (Json.Decode.Decoder Struct.ServerReply.Type) -internal_decoder reply_type = - case reply_type of - "okay" -> (Comm.Okay.decoder) - "set_battles" -> (Comm.SetBattles.decoder) - other -> - (Json.Decode.fail - ( - "Unknown server command \"" - ++ other - ++ "\"" - ) - ) - -decoder : (Json.Decode.Decoder Struct.ServerReply.Type) -decoder = - (Json.Decode.field "msg" Json.Decode.string) - |> (Json.Decode.andThen (internal_decoder)) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -try_sending : ( - Struct.Model.Type -> - String -> - (Struct.Model.Type -> (Maybe Json.Encode.Value)) -> - (Maybe (Cmd Struct.Event.Type)) - ) -try_sending model recipient try_encoding_fun = - case (try_encoding_fun model) of - (Just serial) -> - (Just - (Http.send - Struct.Event.ServerReplied - (Http.post - recipient - (Http.jsonBody serial) - (Json.Decode.list (decoder)) - ) - ) - ) - - Nothing -> Nothing |


