Skip to content

Commit

Permalink
[web-pubsub-client's sample] Update package.json dependency from 'nex…
Browse files Browse the repository at this point in the history
…t' to 'latest' for azure/web-pubsub-client (#30988)

### Packages impacted by this PR


### Issues associated with this PR


### Describe the problem that is addressed by this PR

When we run install packages for two samples
(`sdk\web-pubsub\web-pubsub-client\samples\v1-beta\(javascript/typescript`).
We will receive error:

```
npm error code ETARGET
npm error notarget No matching version found for @azure/web-pubsub-client@next.
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.
npm error A complete log of this run can be found in: C:\.tools\.npm\_logs\2024-09-04T07_49_59_892Z-debug-0.log
```

Because there is no `next` version of `web-pubsub-client` package. So we
can use `latest` version

[Reference the
version](https://www.npmjs.com/package/@azure/web-pubsub-client?activeTab=versions)

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)

---------

Co-authored-by: Duong Phan <dphan@microsoft.com>
  • Loading branch information
phanthaiduong22 and Duong Phan authored Sep 10, 2024
1 parent 9e6b7e9 commit df703d7
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 22 deletions.
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

0 comments on commit df703d7

Please sign in to comment.