Demo that fans out cards from a mothership to clients.
Built applications available through AppCenter
Flavor | Submit build request | Build status |
---|---|---|
Web server | Submit pull request | |
Mothership | Submit pull request | |
UWP client | Submit pull request | |
Android client | Submit pull request | |
iOS client | N/A, not on build server yet |
The client needs to connect to a https website and then use web sockets to receive cards from the mothership.
- Display available motherships to connect to
- When user selects a mothership, connect to it, and once received
ClientName
, go to the Chat page - When received mothership disconnected event or socket closed, go back to showing available motherships
Use a HTTP GET request to retrieve all current motherships.
Request URL: https://cardfanout.azurewebsites.net/api/motherships
Response: A JSON array of strings (mothership names).
[ "Vulcan", "Tucson", "Miami" ]
Display these to the user in a list, letting them click the mothership they want to connect to.
When a user selected a mothership, you now have the mothership name. You'll need that to connect. You'll have to open a web socket. Insert the mothership name in the URL as seen below.
Web Socket URL: wss://cardfanout.azurewebsites.net/wsClient/[MOTERSHIPNAME]
After you've connected to the web socket, you'll have to start receiving messages. You don't need to send messages, so no need to add code for that!
There's three messages you need to handle receiving... They're all JSON serialized, and the Type
property lets you know which type of message they are.
This is the first message that you should receive immediately upon connecting to the web socket.
When you receive this, grab the ClientName
you were assigned and then display the Chat page (you should display the ClientName
at the top of the Chat page so that we can know which client you are).
{
"Type": "ClientNameAssigned",
"ClientName": "[yourAssignedName]"
}
When you receive this, display the card in the chat UI using the CardJson
. You can ignore the CardIdentifier
, it's currently not used in clients and probably won't ever be used.
Note that you must handle receiving MULTI-PART messages. The max size sent is 4 KB (I tried increasing this, but for some reason when deployed to Azure it keeps limiting it down to 4 KB, couldn't figure it out after 2 hours of searching), so payloads larger than that will be separated into multiple parts. Web sockets have an "End of message" flag that indicates whether the message is finished, or whether there's another message on its way.
{
"Type": "MothershipSendCard",
"CardIdentifier": "[guid]",
"CardJson": "[cardJson]"
}
When you receive this, navigate back to the connect to motherships page (and if possible, inform the user that the mothership was disconnected).
{
"Type": "MothershipDisconnected"
}