Skip to content

Commit

Permalink
README changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WarstekHUN committed Dec 26, 2023
1 parent c01b54a commit 4f879b7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 40 deletions.
13 changes: 2 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# New Features
# v2.0.4

- Timeout for waiters
- Set the timeout with `client.maxWaiterTime`
- `waiterTimeout` function with a max waiting time parameter

- The server-side (^1.2) can now set cookies.
- New local events:
- onCookieSet
- onCookieDelete
- Cookie syncing: `syncCookies`

* README changes
84 changes: 58 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,78 @@
# ZilaWS Client
### ZilaWS is a blazingly fast and very lightweight library that provides an extremely easy-to-use way to transmit data via websockets between client-side and server-side using eventhandlers and async waiters.

ZilaWS is a blazingly fast and very lightweight library that provides an extremely easy-to-use way to transmit data via websockets between client-side and server-side using eventhandlers and async waiters

<div style="text-align: center;">
<a style="padding: 2px;" href="https://github.com/ZilaWS/client/actions/workflows/test.yml">
<img style="padding: 2px;" src="https://github.com/ZilaWS/client/actions/workflows/test.yml/badge.svg">
</a>
<img style="padding: 2px;" src="https://img.shields.io/badge/License%20-%20MIT%20-%20brightgreen">
<br>
<img style="padding: 2px;" src="./.coverage-badges/badge-branches.svg">
<img style="padding: 2px;" src="./.coverage-badges/badge-functions.svg">
<img style="padding: 2px;" src="./.coverage-badges/badge-lines.svg">
<img style="padding: 2px;" src="./.coverage-badges/badge-statements.svg">
</div>
[![Test status badge](https://github.com/ZilaWS/client/actions/workflows/test.yml/badge.svg)](https://github.com/ZilaWS/client/actions/workflows/test.yml)
![MIT License](https://img.shields.io/badge/License%20-%20MIT%20-%20brightgreen)
![coverage label for branches](./.coverage-badges/badge-branches.svg)
![coverage label for functions](./.coverage-badges/badge-functions.svg)
![coverage label for lines of code](./.coverage-badges/badge-lines.svg)
![coverage label for statements](./.coverage-badges/badge-statements.svg)

<div style="text-align: center; margin-block: 30px;">
<img src="logo.png" width="240">
</div>
<img src="logo.png" width="240">

<h2 style="text-align: center">
<a href="https://zilaws.com" target="_blank" rel="noopener noreferrer">Documentation</a>
</h2>
## [Documentation](https://zilaws.com)

<h2 style="text-align: center">Looking for the <a href="https://www.npmjs.com/package/zilaws-server" target="_blank" rel="noopener noreferrer">zilaws-server</a> package?</h2>
## Looking for the [zilaws-server](https://www.npmjs.com/package/zilaws-server) package?</h2>

<p>ZilaWS can establish WS connection to a non zilaws server, but won't work as expected.</p>
ZilaWS can establish WS connection to a non zilaws server, but won't work as expected.

<h2>
Waiter example
</h2>
## Waiters

ZilaWS has a unique function called `waiter`. Waiters (as their name suggests) can be awaited.
They resolve when the client side *MessageHandler* resolves or returns thus making it perfect for retrieving data from a client.
However if the client does not respond in time, waiters will resolve as *undefined*.

### Parameters

#### Regular waiters

Regular waiters wait for a response for the amount of time specified by the `maxWaiterTime` property. This is a property of the client.

* `identifier`: The name of the [MessageHandler](https://zilaws.com/docs/server-api/recieving-data#waiting-for-data) on the other side of the connection.
* `...data`: A waiter (or a send) can be given any number of any data.

```ts
socket.waiter<T>(identifier: string, ...data: any[]): Promise<T | undefined>
```

#### Timeout Waiters

<!-- `WaiterTimeout`s wait until the maxWaiting -->
* `maxWaitingTime`: This paramater overrides the maximum waiting time for the corresponding `waiter`. The value is in miliseconds.

```ts
socket.waiterTimeout<T>(identifier: string, maxWaitingTime: number, ...data: any[]): Promise<T | undefined>
```

### Example

### Client

```ts
const client = await connectTo("wss://yourhost.com");
const client = await connectTo("wss://yourhost.com:6589");

console.log(await client.waiter("GetValueOfPI", "Some string") as number); // --> 3.141592653589793
console.log(await client.waiterTimeout("GetValueOfPI", 1200, "Some string") as number); // --> 3.141592653589793
```

### Server

```ts
client.setMessageHandler("SomeIdentifier", (param1: string) => {
const server = new ZilaServer({
port: 6589,
https: {
pathToCert: "cert/fullchain.pem",
pathToKey: "cert/privkey.pem"
}
});

server.setMessageHandler("GetValueOfPI", (param1: string) => {
console.log(param1); // --> Some string
return Math.PI;
});
```
```

## More

ZilaWS offers much more. Check out the [documentation](https://zilaws.com/)!
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "zilaws-client",
"version": "2.0.3",
"version": "2.0.4",
"description": "ZilaWS is a blazingly fast and very lightweight library that provides an extremely easy-to-use way to transmit data via websockets between client-side and server-side using eventhandlers and async waiters.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit 4f879b7

Please sign in to comment.