https://github.com/garronej/chan-dongle-extended-client
https://garronej.github.io/chan-dongle-extended-pages/
https://github.com/garronej/chan-dongle-extended-client
Last synced: 3 months ago
JSON representation
https://garronej.github.io/chan-dongle-extended-pages/
- Host: GitHub
- URL: https://github.com/garronej/chan-dongle-extended-client
- Owner: garronej
- Created: 2017-03-28T09:36:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-22T18:43:54.000Z (over 2 years ago)
- Last Synced: 2025-02-05T11:18:55.441Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 305 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chan-dongle-extended-client
This is the client for [chan-dongle-extended](https://github.com/garronej/chan-dongle-extended).
[Website of the project](https://garronej.github.io/chan-dongle-extended-pages/)
## Installation
`package.json`
```json
"dependencies": {
"chan-dongle-extended-client": "github:garronej/chan-dongle-extended-client",
}
```## Usage
```typescript
import { DongleController as Dc } from "chan-dongle-extended-client";/** Once it resolve Dc.getInstance() can be used synchronously */
const prDongleControllerInitialized = new Promise(async resolve => {// This is the port used by default if you didn't specified another explicitely in the chan-dongle-extended config.
const { port } = await import("chan-dongle-extended-client/dist/lib/misc");await new Promise(resolve => setTimeout(resolve, 3000));
while (true) {
const dc = Dc.getInstance("127.0.0.1", port);
try {
await dc.prInitialization;
} catch{
debug("dongle-extended not initialized yet, scheduling retry...");
await new Promise(resolve => setTimeout(resolve, 3000));
continue;
}
dc.evtClose.attachOnce(
() => {
Promise.reject(new Error("TCP connection lost with chan-dongle-extended"))
}
);break;
}
resolve();
});
prDongleControllerInitialized.then(()=> {
const dc = Dc.getInstance();
dc.createContact(...)
dc.sendMessage(...)
dc.evtMessage.attach(message=> { ... })});
```Chan dongle-extended-client is used to build the CLI that you use with chan-dongle-extended: [see code](https://github.com/garronej/chan-dongle-extended/blob/master/src/bin/cli.ts).
If you need more insight, you can try revers engineering the usage of `chan-dongle-extended-client` in [this project](https://github.com/garronej/semasim-gateway).