Types used by the rest of the WebSocketFramework modules.
{ dicts : Dicts gamestate player
, publicGames : PublicGames
, state : Maybe gamestate
, seed : Random.Seed
, changes : Maybe Changes
, statistics : Maybe Statistics
, time : Time.Posix
}
The part of the server state that is independent from its socket connections.
To access the opaque dicts
, use addGame
, addPlayer
, getGame
, getPlayer
, getGamePlayers
, updateGame
, updatePlayer
, removeGame
, removePlayer
from WebsocketFramework.ServerInterface
.
WebSocketFramework.InternalTypes.DictsWrapper (WebSocketFramework.InternalTypes.ServerDicts gamestate player)
Opaque type used to store game and player state.
Everything necessary to communicate with a server, be it real or proxy.
{ gameid : GameId
, player : player
}
Information about a player in a game.
{ gameid : GameId
, playerName : String
}
If your server supports public games, this represents the game id and name of the creator of the game.
List PublicGame
A list of pubic games.
{ addedGames : List GameId
, addedPlayers : List ( GameId
, PlayerId )
, removedGames : List ( GameId
, List PlayerId )
, removedPlayers : List ( GameId
, PlayerId )
}
Used to inform the server of added and removed games and players.
Interact with it via ServerInterface.addGame
, addPlayer
, removeGame
, removePlayer
.
emptyServerState : Maybe gamestate -> ServerState gamestate player
Create a mostly empty ServerState
.
You'll need to initialize the seed
property in your real server,
if you use newGameid
and newPlayerid
in WebSocketFramework.ServerInterface
.
You'll need to initialize the statistics
property, if you want to
track statistics.
emptyPublicGames : PublicGames
An empty list of public games.
{ reqrsp : String
, msg : String
, plist : Plist
}
A raw request, ready to be encoded to go over the wire.
reqrsp
is "req" or "rsp" for request or response.
msg
is the name of the message.
plist
is the parameters of the message.
A type safe representation of the reqrsp
and msg
fields of a RawMessage
.
List ( String
, Json.Encode.Value
}
A list of key/value pairs.
{ request : message
, text : String
}
An error response that encapsulates a request message and an error string.
ServerState gamestate player -> message -> ( ServerState gamestate player
, Maybe message
}
Type signature of a function which turns a server state and a request message into a ServerState and maybe a response message.
message -> Maybe GameId
Type signature of a function that extracts the game id from a message, if it has one.
gamestate -> message -> Result String Basics.Never
Type signature of a function that checks if a message is a legal request for a gamestate.
An Err
result has a message string. An Ok
result maps an unusable value.
( ReqRsp
, Plist ) -> Result String messag
)
Type signature for a function that turns a request or response and a key/value list into a message.
message -> ( ReqRsp
, Plist
}
Type signature for a function that turns a message into request or response and a key/value list.
{ encoder : MessageEncoder message
, decoder : MessageDecoder message
, errorWrapper : Maybe (Error message -> message)
}
Wrapping of encoder, decoder, and error message creator.
List ( String
, Json.Decode.Decoder msg
}
Map a list of request or response names to decoders for their messages.
Dict String Basics.Int
Track statistics about connections and games.
emptyStatistics : Statistics
Return a new Statistics
record, with your value for the statistics
field.
Until you populate the ServerState.statistics field, no connection statistics will be gathered.
printifyString : String -> String
Convert ASCII double-quote characters to curly end quotes.
(Json.Encode.Value -> msg) -> Platform.Sub.Sub msg
The input port from the Node.js code to the WebSocket server.
Json.Encode.Value -> Platform.Cmd.Cmd msg
The output port from the WebSocket server to the Node.js code.
The kind of error being reported in an Error
instance.
{ kind : ErrorKind
, description : String
, message : Result String message
}
Description of an error passed to EncodeDecode.errorWrapper
.
If kind
is JsonParseError
, then description
is the message text,
and message
is the error returned from parsing it.
If kind
is UnspecifiedError
, then description
is user-level text,
and message
is Ok
wrapped around the relevant message, if there
is one, or Err
wrapped around some likely useless string.
WebSocketFramework.InternalTypes.GameId
An alias for String
.
WebSocketFramework.InternalTypes.PlayerId
An alias for String
.
String
An alias for String
.