generated from WarstekHUN/typescript-npm-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c01b54a
commit 4f879b7
Showing
4 changed files
with
63 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/)! |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters