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
3. Add configuration so that the server can connect with your Web PubSub for Socket.IO resource.
39
+
40
+
3. Locate in your server-side code where Socket.IO server is created and wrap it with `useAzureSocketIO()`:
41
41
```javascript
42
-
const wpsOptions = {
42
+
const io = require("socket.io")();
43
+
useAzureSocketIO(io, {
43
44
hub: "eio_hub", // The hub name can be any valid string.
44
45
connectionString: process.argv[2]
45
-
};
46
-
```
47
-
48
-
4. Locate in your server-side code where Socket.IO server is created and append `.useAzureSocketIO(wpsOptions)`:
49
-
```javascript
50
-
const io = require("socket.io")();
51
-
useAzureSocketIO(io, wpsOptions);
46
+
});
52
47
```
53
-
>[!IMPORTANT]
54
-
>`useAzureSocketIO` is an asynchronous method. Here we`await`. So you need to wrap it and related code in an asynchronous function.
48
+
>[!IMPORTANT]
49
+
>`useAzureSocketIO` is an asynchronous method and it does initialization steps to connect to Web PubSub. You can`await useAzureSocketIO(...)` or use `useAzureSocketIO(...).then(...)` to make sure your app server starts to serve requests after the initialization succeeds.
55
50
56
-
5. If you use the following server APIs, add `async` before using them as they're asynchronous with Web PubSub for Socket.IO.
51
+
4. If you use the following server APIs, add `async` before using them as they're asynchronous with Web PubSub for Socket.IO.
0 commit comments