https://github.com/advplyr/abs-socket-client-demo
Demo of setting up an authenticated socket connection for audiobookshelf
https://github.com/advplyr/abs-socket-client-demo
Last synced: 3 months ago
JSON representation
Demo of setting up an authenticated socket connection for audiobookshelf
- Host: GitHub
- URL: https://github.com/advplyr/abs-socket-client-demo
- Owner: advplyr
- Created: 2022-11-26T18:11:48.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-26T18:23:39.000Z (over 2 years ago)
- Last Synced: 2025-02-23T02:44:25.132Z (3 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Audiobookshelf Socket Client Demo
This is just an example of establishing an authenticated socket connection for audiobookshelf.
On the server a user can have many socket clients. This means you can login as the same user in multiple browser windows and they will all receive events for that user.
The demo works like this:
1. Initialize the socket client
2. Login to the server using the audiobookshelf API
3. Emit a socket event 'auth' with the users API tokenOnce that is done the user will be linked to that socket connection and all events emitted from the server intended for that user will be received by the client.
**Note: if the socket gets disconnected and re-connects it will have a new socket id and needs to emit the 'auth' event again.**
## Installation
Node v16 or higher is required.
```bash
git clone https://github.com/advplyr/abs-socket-client-demo.git
cd abs-socket-client-demo
npm install
```## Usage
First update the `config.json` with your server info.
For example if your server is running `https://abs.example.com` then your config would look like:
```json
{
"protocol": "https",
"hostname": "abs.example.com",
"port": 443,
"username": "root",
"password": ""
}
```
Replace username/password with yours.To run the demo make sure you are in the `abs-socket-client-demo` folder then..
```bash
npm run start
```If you leave this running and login to the same user in a browser then you will see in the console all the events being sent for that user.
To test this you can update a library item in the browser and you should see an `item_updated` event in the console with the full library item object.