Coder Social home page Coder Social logo

janus-java-sdk's Introduction

Janus SDK Quickstart

Janus SDK Client currently use WebSocket to connect Janus Gateway, To use it you must have Janus WebSocket URL.


How to use ?

This sdk use CompletableFuture for async tasks, for more information you can take a look to this tutorials :

1. Create JanusClient instance

var janusClient = new JanusWebSocketClient("ws://voice.kavenegar.com:8188/", new JanusEventListener() {});
janusClient.connect();

2. Create janus session

janusClient.create().thenAccept(session -> {
    logger.info("Session created , id : {}",session.getId());        
}).exceptionally(error -> {
    logger.error("Error in creating session {}",error));
    return null;
});

3. Attach a plugin into session

You can set opaque_id for accessing handle in session.

session.attach(JanusPluginType.AUDIO_BRIDGE,"OPAQUE_ID").thenAccept(handle -> {
    if(handle instanceof AudioBridgeHandle audioBridge){
        // It's audio brdige plugin instance you can call plugin requests
    }
}).exceptionally(error -> {
    logger.error("Error in attaching handle to session {}",error));
    return null;
});

For example after creating handle you can get handle by opaque_id like this :

var handle = (AudioBridgeHandle) session.mediaSession().getHandle(endpoint.getUsername()).get();

4. Execute plugin commands

handle.create(new AudioBridgeCreateRoomRequest(1012)).thenAccept(created -> {
    // room is created    
});

5. Configure Room

handle.configure(new AudioBridgeConfigureRequest(false, "OFFER_SDP")).thenAccept(answer -> {
    // answer is here
});

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.