Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web-pubsub-client's sample] Update package.json dependency from 'next' to 'latest' for azure/web-pubsub-client #30988

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ languages:
- javascript
products:
- azure
urlFragment: web-pubsub-client-javascript-beta
urlFragment: web-pubsub-client-javascript
---

# Azure Web PubSub Client client library samples for JavaScript (Beta)
# Azure Web PubSub Client client library samples for JavaScript

These sample programs show how to use the JavaScript client libraries for Azure Web PubSub Client in some common scenarios.

Expand Down Expand Up @@ -53,6 +53,7 @@ npx cross-env WPS_CONNECTION_STRING="<wps connection string>" node helloworld.js

Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients.

[helloworld]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/web-pubsub/web-pubsub-client/samples/v1-beta/javascript/helloworld.js
[helloworld]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/web-pubsub/web-pubsub-client/samples/v1/javascript/helloworld.js
[apiref]: https://docs.microsoft.com/javascript/api/@azure/web-pubsub-client
[freesub]: https://azure.microsoft.com/free/
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/web-pubsub/web-pubsub-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ async function main() {
if (e.message.data instanceof ArrayBuffer) {
console.log(`Received message ${Buffer.from(e.message.data).toString("base64")}`);
} else {
console.log(`Received message ${e.message.data}`);
console.log(`Received message ${JSON.stringify(e.message.data)}`);
}
});

client.on("group-message", (e) => {
if (e.message.data instanceof ArrayBuffer) {
console.log(
`Received message from ${e.message.group} ${Buffer.from(e.message.data).toString("base64")}`
`Received message from ${e.message.group} ${Buffer.from(e.message.data).toString("base64")}`,
);
} else {
console.log(`Received message from ${e.message.group} ${e.message.data}`);
console.log(`Received message from ${e.message.group} ${JSON.stringify(e.message.data)}`);
}
});

Expand All @@ -65,7 +65,7 @@ async function main() {
await client.sendToGroup(
groupName,
buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength),
"binary"
"binary",
);
await delay(1000);
await client.stop();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@azure-samples/web-pubsub-client-js-beta",
"name": "@azure-samples/web-pubsub-client-js",
"private": true,
"version": "1.0.0",
"description": "Azure Web PubSub Client client library samples for JavaScript (Beta)",
"description": "Azure Web PubSub Client client library samples for JavaScript",
"engines": {
"node": ">=18.0.0"
},
Expand All @@ -22,7 +22,7 @@
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/web-pubsub/web-pubsub-client",
"dependencies": {
"@azure/web-pubsub-client": "next",
"@azure/web-pubsub-client": "latest",
"dotenv": "latest",
"@azure/web-pubsub": "^1.1.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ languages:
- typescript
products:
- azure
urlFragment: web-pubsub-client-typescript-beta
urlFragment: web-pubsub-client-typescript
---

# Azure Web PubSub Client client library samples for TypeScript (Beta)
# Azure Web PubSub Client client library samples for TypeScript

These sample programs show how to use the TypeScript client libraries for Azure Web PubSub Client in some common scenarios.

Expand Down Expand Up @@ -65,7 +65,8 @@ npx cross-env WPS_CONNECTION_STRING="<wps connection string>" node dist/hellowor

Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients.

[helloworld]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/web-pubsub/web-pubsub-client/samples/v1-beta/typescript/src/helloworld.ts
[helloworld]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/web-pubsub/web-pubsub-client/samples/v1/typescript/src/helloworld.ts
[apiref]: https://docs.microsoft.com/javascript/api/@azure/web-pubsub-client
[freesub]: https://azure.microsoft.com/free/
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/web-pubsub/web-pubsub-client/README.md
[typescript]: https://www.typescriptlang.org/docs/home.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@azure-samples/web-pubsub-client-ts-beta",
"name": "@azure-samples/web-pubsub-client-ts",
"private": true,
"version": "1.0.0",
"description": "Azure Web PubSub Client client library samples for TypeScript (Beta)",
"description": "Azure Web PubSub Client client library samples for TypeScript",
"engines": {
"node": ">=18.0.0"
},
Expand All @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/web-pubsub/web-pubsub-client",
"dependencies": {
"@azure/web-pubsub-client": "next",
"@azure/web-pubsub-client": "latest",
"dotenv": "latest",
"@azure/web-pubsub": "^1.1.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import {
WebPubSubClient,
WebPubSubClientCredential,
SendToGroupOptions,
GetClientAccessUrlOptions,
} from "@azure/web-pubsub-client";
import { WebPubSubServiceClient } from "@azure/web-pubsub";
Expand Down Expand Up @@ -44,17 +43,19 @@ async function main() {
if (e.message.data instanceof ArrayBuffer) {
console.log(`Received message ${Buffer.from(e.message.data).toString("base64")}`);
} else {
console.log(`Received message ${e.message.data}`);
console.log(`Received message ${JSON.stringify(e.message.data)}`);
}
});

client.on("group-message", (e) => {
if (e.message.data instanceof ArrayBuffer) {
console.log(
`Received message from ${e.message.group} ${Buffer.from(e.message.data).toString("base64")}`
`Received message from ${e.message.group} ${Buffer.from(e.message.data).toString(
"base64",
)}`,
);
} else {
console.log(`Received message from ${e.message.group} ${e.message.data}`);
console.log(`Received message from ${e.message.group} ${JSON.stringify(e.message.data)}`);
}
});

Expand All @@ -63,14 +64,14 @@ async function main() {
await client.joinGroup(groupName);
await client.sendToGroup(groupName, "hello world", "text", {
fireAndForget: true,
} as SendToGroupOptions);
});
await client.sendToGroup(groupName, { a: 12, b: "hello" }, "json");
await client.sendToGroup(groupName, "hello json", "json");
var buf = Buffer.from("aGVsbG9w", "base64");
await client.sendToGroup(
groupName,
buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength),
"binary"
"binary",
);
await delay(1000);
await client.stop();
Expand Down
Loading