You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Quickstart: Incorporate Web PubSub for Socket.IO in your app
13
13
14
-
This quickstart is for existing Socket.IO users. It demonstrates how quickly you can incorporate Web PubSub for Socket.IO in your app to simplify development, speed up deployment, and achieve scalability without complexity.
14
+
This quickstart demonstrates how to create a Web PubSub for Socket.IO resource and quickly incorporate it in your Socket.IO app to simplify development, speed up deployment, and achieve scalability without complexity.
15
15
16
16
Code shown in this quickstart is in CommonJS. If you want to use an ECMAScript module, see the [chat demo for Socket.IO with Azure Web PubSub](https://github.com/Azure/azure-webpubsub/tree/main/experimental/sdk/webpubsub-socketio-extension/examples/chat).
17
17
@@ -23,13 +23,37 @@ Code shown in this quickstart is in CommonJS. If you want to use an ECMAScript m
23
23
24
24
## Create a Web PubSub for Socket.IO resource
25
25
26
-
1. Go to the [Azure portal](https://portal.azure.com/).
27
-
1. Search for **socket.io**, and then select **Web PubSub for Socket.IO**.
28
-
1. Select a plan, and then select **Create**.
26
+
To create a Web PubSub for Socket.IO, you can use the following one-click button to create or follow the actions below to search in Azure portal.
29
27
30
-
:::image type="content" source="./media/socketio-migrate-from-self-hosted/create-resource.png" alt-text="Screenshot of the Web PubSub for Socket.IO service in the Azure portal.":::
28
+
- Use the following button to create a Web PubSub for Socket.IO resource in Azure
31
29
32
-
## Initialize a Node project and install required packages
30
+
[](https://ms.portal.azure.com/#create/Microsoft.WebPubSubForSocketIO)
31
+
32
+
- Search from Azure portal search bar
33
+
34
+
1. Go to the [Azure portal](https://portal.azure.com/).
35
+
36
+
1. Search for **socket.io**, in the search bar and then select **Web PubSub for Socket.IO**.
37
+
38
+
:::image type="content" source="./media/socketio-quickstart/search.png" alt-text="Screenshot of searching the Web PubSub for Socket.IO service in the Azure portal.":::
39
+
40
+
- Search from Marketplace
41
+
42
+
1. Go to the [Azure portal](https://portal.azure.com/).
43
+
44
+
1. Select the **Create a resource** button found on the upper left-hand corner of the Azure portal. Type **socket.io** in the search box and press enter. Select the **Web PubSub for Socket.IO** in the search result.
45
+
46
+
:::image type="content" source="./media/socketio-quickstart/marketplace.png" alt-text="Screenshot of the Web PubSub for Socket.IO service in the marketplace.":::
47
+
48
+
1. Click **Create** in the pop out page.
49
+
50
+
:::image type="content" source="./media/socketio-migrate-from-self-hosted/create-resource.png" alt-text="Screenshot of the Web PubSub for Socket.IO service in the Azure portal.":::
51
+
52
+
## Sending messages with Socket.IO libraries and Web PubSub for Socket.IO
53
+
54
+
In the following steps, you create a Socket.IO project and integrate with Web PubSub for Socket.IO.
55
+
56
+
### Initialize a Node project and install required packages
When you use Web PubSub for Socket.IO, `<web-pubsub-socketio-endpoint>` and `path` are required for the client to connect to the service. The `<web-pubsub-socketio-endpoint>` and `path` can be found in Azure portal.
95
115
96
-
```javascript
97
-
/*client.js*/
116
+
1. Go to the **key** blade of Web PubSub for Socket.IO
98
117
99
-
// Receives a message from the server
100
-
socket.on("hello", (arg) => {
101
-
console.log(arg);
102
-
});
118
+
1. Type in your hub name and copy the **Client Endpoint** and **Client Path**
103
119
104
-
// Sends a message to the server
105
-
socket.emit("howdy", "stranger")
106
-
```
120
+
:::image type="content" source="./media/socketio-quickstart/client-url.png" alt-text="Screenshot of the Web PubSub for Socket.IO service in the Azure portal client endpoints blade.":::
107
121
108
122
## Run the app
109
123
110
124
1. Run the server app:
111
125
112
126
```bash
113
-
node server.js "<web-pubsub-connection-string>"
127
+
node server.js "<connection-string>"
114
128
```
115
129
130
+
The `<connection-string>` is the connection string that contains the endpoint and keys to access your Web PubSub forSocket.IO resource. You can also find the connection stringin Azure portal
131
+
132
+
:::image type="content" source="./media/socketio-quickstart/connection-string.png" alt-text="Screenshot of the Web PubSub for Socket.IO service in the Azure portal connection string blade.":::
0 commit comments