Giter Site home page Giter Site logo

adaptivecardsfanoutdemo's Introduction

AdaptiveCardsFanOutDemo

Demo that fans out cards from a mothership to clients.

Built applications available through AppCenter

Updating/building website/apps

Flavor Submit build request Build status
Web server Submit pull request
Mothership Submit pull request Build status
UWP client Submit pull request Build status
Android client Submit pull request Build status
iOS client N/A, not on build server yet

How to build a client

The client needs to connect to a https website and then use web sockets to receive cards from the mothership.

General client UX app flow

  1. Display available motherships to connect to
  2. When user selects a mothership, connect to it, and once received ClientName, go to the Chat page
  3. When received mothership disconnected event or socket closed, go back to showing available motherships

Step 1: Access all current 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.

Step 2: Connect to the mothership

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]

Step 3: Receive messages from the mothership web socket

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.

ClientNameAssigned

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]"
}

MothershipSendCard

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]"
}

MothershipDisconnected

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"
}

adaptivecardsfanoutdemo's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.