Support for a Node.js server for WebSocketFramework messages.
The messages processed by our update function.
Connection, Disconnection, and SocketMessage from through the inputPort from the Node.JS code. FirstTick and Tick are used to track time. Noop does nothing.
User function that is called to send the response(s) to a request.
This will usually call sendToOne and/or sendToMany with the message emitted by the ServiceMessageProcessor in the UserFunctions passed to program.
The first message is the request that came from client to server. The second message is the response. If no response is returned by the ServiceMessageProcessor, this function is not called.
The ServerState arg is the value of the state property of the WrappedModel arg, pulled out for your convenience. If you change it, you must put it back in the model you return.
User functions that get called by the generic server code.
encodeDecode is used to translate messages to and from strings.
messageProcessor processes a client request into state changes and a response message.
messageSender decides what to do with the response message.
messageToGameid extracts a GameId from a message, if there is one.
autoDeleteGame is called when all sockets referencing a GameId have disconnected. If it returns True, then the game will be put on deathwatch, meaning it will be removed from the tables after 2 minutes. Usually used to keep public games from being auto-deleted.
inputPort and outputPort are the ports used to communicate with the Node.js code.
A type wrapper to prevent recursive types in Model.
An alias of WebSocketServer.Socket.
Create the top-level application program.
You will usually use the result of this function as the value of main in your top-level module.
Most servers will not need to use the servermodel, but it's a place to stash extra server-wide state that doesn't make sense in the game-specific gamestate.
Return the initial Model and a Cmd to get the current time.
Usually called for you by program.
Encode a message to a single socket via an output port.
If the first arg is True, log the operation on the console.
Encode a message to multiple sockets via an output port.
If the first arg is True, log the operation on the console.
Generate a random GameId string, ensuring that it is not already assigned to a game.
Will not be used by servers that have no concept of a game.
Generate a random PlayerId string, ensuring that it is not already assigned to a player.
Will not be used by servers that have no concept of a player.
Return whether VERBOSE is set in the server's environment
The server application model.
programcreates one of these, via a call toinit.