Code Monkey home page Code Monkey logo

abs-socket-client-demo's Introduction

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 token

Once 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.

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:

{
  "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..

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.

abs-socket-client-demo's People

Contributors

advplyr avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.