docs: doc
This commit is contained in:
49
README.md
49
README.md
@@ -4,55 +4,50 @@
|
||||
|
||||
This is the javascript sdk package required to create a javascript tap server responsible for the audio of `zako`, a discord audio bot.
|
||||
|
||||
## Dependencies
|
||||
|
||||
| package | version |
|
||||
| --- | --- |
|
||||
| eventemitter3 | 5.0.1" |
|
||||
| got | 14.4.7 |
|
||||
| jest | 30.0.4 |
|
||||
| ws | 8.18.3 |
|
||||
| zod | 3.25.72 |
|
||||
|
||||
## Quickstart Example
|
||||
|
||||
First, you need to download `zako-sdk-js` on your project.
|
||||
First, you need to download `tap-sdk-js` on your project.
|
||||
|
||||
```bash
|
||||
npm install zako-sdk-js
|
||||
npm install tap-sdk-js
|
||||
```
|
||||
|
||||
Then, you can use the sdk.
|
||||
Here is some example.
|
||||
|
||||
```js
|
||||
import { createClient } from "zako-sdk-js"
|
||||
import { createClient } from "tap-sdk-js";
|
||||
|
||||
const client = createClient({
|
||||
name: "your zako tap server name",
|
||||
token: "your zako tap server token",
|
||||
zakoEndpoint: "zako endpoint (default is https://api.zako.ac)"
|
||||
name: "your zako tap server name",
|
||||
token: "your zako tap server token",
|
||||
zakoEndpoint: "zako endpoint (default is https://api.zako.ac)",
|
||||
});
|
||||
|
||||
client.events.on("ready", () => {
|
||||
console.log("ready");
|
||||
console.log("ready");
|
||||
});
|
||||
|
||||
client.events.on("request", (handle) => {
|
||||
handle.respond("audio stream on here")
|
||||
const { data, parameters } = handle;
|
||||
// data is the actual data to handle.
|
||||
|
||||
// to respond the stream
|
||||
handle.respond(/* stream here */);
|
||||
|
||||
// call this on error
|
||||
handle.respondError("error message");
|
||||
});
|
||||
|
||||
client.events.on("connectionError", (e) => {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
client.events.on("error", (e) => {
|
||||
console.error(e);
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
client.connect();
|
||||
|
||||
await new Promise((r) => setTimeout(r, 100000));
|
||||
```
|
||||
|
||||
## Client Description
|
||||
@@ -64,6 +59,7 @@ You can create tap server client by call `createClient` function in `tap-sdk-js`
|
||||
You should put the client data written as `ZakoTapConfig` type inside the argument of `createClient`.
|
||||
|
||||
You can then connect to the tab server using `client.connect()`.
|
||||
|
||||
```js
|
||||
import { createClient } from "zako-sdk-js"
|
||||
|
||||
@@ -80,12 +76,15 @@ client.connect();
|
||||
### 2. Client Event
|
||||
|
||||
Using the client created above, you can use client.on to perform a specific function when the EventEmitter's event is called.
|
||||
|
||||
```js
|
||||
client.events.on("event name", function)
|
||||
```
|
||||
|
||||
The types of events are specified in TapEvents among the types in the zakotap package.
|
||||
|
||||
#### Tap Events
|
||||
|
||||
- `ready`: This event is called when the zako tap server successfully connects to the `zako tap hub`.
|
||||
- `request`: This event is called when an `audio request` is received from the `zako tap hub`.
|
||||
- `connectionError`: This event is called when an connection error occurs within the zakotap package.
|
||||
@@ -94,9 +93,11 @@ The types of events are specified in TapEvents among the types in the zakotap pa
|
||||
### 3. Send Audio
|
||||
|
||||
You can send your audio stream by using `handle.respond()` function.
|
||||
|
||||
```js
|
||||
handle.respond("your audio stream")
|
||||
handle.respond("your audio stream");
|
||||
```
|
||||
|
||||
You can get `audio request handle` from request event parameter. If you don't send an audio stream, your tap server will be considered offline and you may be disconnected.
|
||||
|
||||
## Work Flow
|
||||
@@ -114,8 +115,10 @@ sequenceDiagram
|
||||
```
|
||||
|
||||
## Related Documents
|
||||
|
||||
- [Zako 2]()
|
||||
- [Protocol Specification]()
|
||||
|
||||
## Authors
|
||||
|
||||
- [@ridanit-ruma](https://github.com/ridanit-ruma) (Discord: `ruma0607`)
|
||||
|
||||
Reference in New Issue
Block a user