|
| 1 | +--- |
| 2 | +title: Use LiveTry to try out the capabilities of Azure Web PubSub |
| 3 | +description: How to use LiveTry to explore service capabilities without setting up a code project |
| 4 | +author: kevinguo-ed |
| 5 | +ms.author: kevinguo |
| 6 | +ms.service: azure-web-pubsub |
| 7 | +ms.topic: overview |
| 8 | +ms.date: 05/27/2025 |
| 9 | +--- |
| 10 | + |
| 11 | +# Use LiveTry to explore Azure Web PubSub capabilities |
| 12 | + |
| 13 | +**LiveTry** is a browser-based tool that helps you use Azure Web PubSub’s real-time messaging features—no code or local setup required. With just a few clicks, you can create clients, join groups, and send messages using both client-side and server-side APIs. |
| 14 | + |
| 15 | +This guide walks you through two common messaging scenarios in LiveTry, while helping you understand important concepts like **connections**, **groups**, and **messages**. |
| 16 | + |
| 17 | +## What you learn |
| 18 | + |
| 19 | +You explore two messaging patterns often used in real-time applications: |
| 20 | + |
| 21 | +- **Server-to-group messaging**: Using the `sendToGroup` API to broadcast messages to all clients in a group. |
| 22 | +- **Client-to-group messaging**: Azure Web PubSub supports a capability that allows a client in a group to send messages directly to other clients in the same group—**without routing through your app server**—reducing latency. |
| 23 | + |
| 24 | +## Key concepts |
| 25 | + |
| 26 | +Before we get started, here’s a quick refresher on core Azure Web PubSub concepts that you interact with in LiveTry: |
| 27 | + |
| 28 | +- **Hub**: A logical unit used to isolate and organize messaging logic. Clients always connect to a hub. With LiveTry, real traffic goes through the resource. For this tutorial, we recommend specifying a test hub name that doesn’t overlap with your production traffic. |
| 29 | +- **Connection**: A persistent WebSocket connection between a client and the Azure Web PubSub service. |
| 30 | +- **Group**: A server-managed subset of connections. Messages sent to a group are delivered only to the connections within that group. |
| 31 | +- **Messages**: The payloads exchanged between clients and the service. Messages can be broadcast to all, targeted to groups, or directed to individual connections. |
| 32 | + |
| 33 | +## Scenario 1: Send a message to a group from the server |
| 34 | + |
| 35 | +In this scenario, you simulate server-side broadcasting using the `sendToGroup` REST API. This scenario demonstrates how the service routes a message from your backend to all clients in a specified group. |
| 36 | + |
| 37 | +### Steps |
| 38 | +1. In the Azure portal, navigate to your Azure Web PubSub resource. |
| 39 | +2. Open the **LiveTry** blade. |
| 40 | +3. Click **+ Add Client** to create multiple connections. |
| 41 | +4. Assign each client to a group (for example, `group1`). |
| 42 | +5. Under the **Server** tab in the "Publish messages" section, select **Send to group**. |
| 43 | +6. Enter the group name (`group1`), a sample message, and invoke the `sendToGroup` API. |
| 44 | +7. Switch to the **Client** tab and observe the message appear in each client's message log. |
| 45 | + |
| 46 | +### What you’re learning |
| 47 | +You send messages to a group of clients using RESTful APIs. LiveTry demonstrates how server-to-group communication works without needing to deploy a backend. Azure Web PubSub also provides server SDKs for C#, JavaScript, Java, and Python. |
| 48 | + |
| 49 | +To visualize message broadcasting in action, try repeating the steps with multiple clients. LiveTry supports up to five concurrent simulated clients. |
| 50 | + |
| 51 | +## Scenario 2: Send a message to a group from a client |
| 52 | + |
| 53 | +In this scenario, you create a client sending a message to other clients in the same group—similar to a user posting a message in a chat room. |
| 54 | + |
| 55 | +### Steps |
| 56 | +1. In **LiveTry**, add two or more clients and specify the same value for the `Initial Groups` field. |
| 57 | +2. For the client that sends the message, select **Allow client to send to all groups**. |
| 58 | +3. Switch to that client’s panel, specify the group name, enter a message, and click **Invoke**. |
| 59 | +4. The other clients in the group receive the message in real time. |
| 60 | + |
| 61 | +### What you’re learning |
| 62 | +This scenario showcases **client-to-group messaging**, which is ideal in applications where server round-trips introduce unnecessary latency. It's a core part of Web PubSub’s **client publish/subscribe model**. |
| 63 | + |
| 64 | +> [!TIP] |
| 65 | +> Open multiple browser tabs to simulate multiple users or devices. |
| 66 | +> Try combining more operations like `joinGroup`, `leaveGroup`, or `sendToConnection`. |
| 67 | +> Use clear group names to better organize your experiments. |
| 68 | +
|
| 69 | +## Next steps |
| 70 | + |
| 71 | +- Learn more about [key concepts](./key-concepts.md) in Azure Web PubSub |
| 72 | +- To build a local sample, follow the [Quickstart guide](./quickstarts-pubsub-among-clients.md) |
| 73 | +- Explore guides under "How-to guides" for common tasks when developing with Azure Web PubSub |
0 commit comments