Seiji Villafranca
github.com/SeijiV13
seijivillafranca.com
Hi im Seiji!
A filipino developer based in the Netherlands, I write code, i teach people and i speak in conferences
Developer
Community Lead / Speaker
Author
What is Azure Fluid Relay?
We want Real-time collaboration!
Real time updates
Seamless data flow
give updates
receive updates!
The Common Way?
Handling front and back
Client Web App
Service
Storage
Handling updates
Merge update conflicts
Receive updates in client
Web Sockets
Azure Fluid Relay Collaboration
Client Web App
Service
Storage
Azure Fluid Relay
Server side is handled by Fluid
What is Azure Fluid Relay?
Very low latency.
Client-centric application model
Distributed data structures
fluid handles the server logic
zero custom code on the server
responsible for taking in data operations, sequencing the operations, and returning the sequenced operations to the clients.
Step 1
Client code changes data locally.
Dice Roller App
User rolls the dice
const updateDice = () => {
const diceValue = diceMap.get(diceValueKey);
// Unicode 0x2680-0x2685 are the sides of a dice (⚀⚁⚂⚃⚄⚅)
dice.textContent = String.fromCodePoint(0x267f + diceValue);
dice.style.color = `hsl(${diceValue * 60}, 70%, 30%)`;
};Step 2
Sends the change to fluid service
Dice Roller App
rollButton.onclick = () =>
diceMap.set(diceValueKey, Math.floor(Math.random() * 6) + 1);
Step 3
Fluid service sequences that operation and broadcasts to all clients
Fluid Service
Container
broadcast
state
get data state
Step 4
incorporates that operation into local data and raises a "valueChanged" event.
diceMap.on("valueChanged", updateDice);Step 5
Clients connected handles the changes
const updateDice = () => {
const diceValue = diceMap.get(diceValueKey);
// Unicode 0x2680-0x2685 are the sides of a dice (⚀⚁⚂⚃⚄⚅)
dice.textContent = String.fromCodePoint(0x267f + diceValue);
dice.style.color = `hsl(${diceValue * 60}, 70%, 30%)`;
};Three primary concepts for building an application with Fluid.
Service
Container
Shared objects
Service
A centralized service to send and receive data and operations
@fluidframework/azure-client.
package for connecting the Azure fluid relay service
Container
Collection of shared objects that contain data that is shared with different clients
const schema = {
2 initialObjects: {
3 layout: SharedMap,
4 },
5};
6
7const { container, services } =
8 await client.createContainer(schema);
9
10const containerId = await container.attach();Shared Objects
Shared Data with different clients
Distributed Data Structures and Data Objects
A Quick Demo!
Lets summarize
Low latency
Worry about the front-end code only
Collaboration using containers
Other Advantages
Available Recipes
References
github.com/SeijiV13
seijivillafranca.com
fb.com/seiji.villafranca
Thank you
and happy coding!