Git Product home page Git Product logo

sdk-component-adapter's Introduction

Webex SDK Component Adapter

Webex adapter to share SDK data with the components

CircleCI npm latest version semantic-release license

Webex SDK Adapter is a library of adapters to provide live data from Webex JavaScript SDK to Webex Components.

Project Status

The Webex Component System is considered to be in beta stage and it's not a generally available product from Webex at this time. This means that the Webex Component System is available for everyone to use but breaking changes may occur as we develop it. We try our best to minimize any breaking changes but they may occur. While the Webex Component System is not a GA product, we still offer support through all regular channels. However, bug priority is given to products already generally available. We would love for you to use the Webex Component System and be part of the feedback process!

Table of Contents

Install

npm install --save @webex/components @webex/sdk-component-adapter

Usage

Setup

When using the Webex SDK Adapter, it is expected to have a fully authenticated SDK instance passed to it:

const webex = new Webex({
  credentials: `<YOUR WEBEX ACCESS_TOKEN>`,
});

const adapter = new WebexSDKAdapter(webex);

Connect

The Webex SDK requires different connections to be setup in order for it to be usable. Some examples of these connections include device registration and web socket connections.

These connections are handled by the SDK Adapter, but require the connect function to be manually called.

const webex = new Webex({
  credentials: `<YOUR WEBEX ACCESS_TOKEN>`,
});

const adapter = new WebexSDKAdapter(webex);

await adapter.connect();

// Adapter is now ready to make requests.

Disconnect

When the adapter is no longer going to be used, the disconnect function will do the necessary tear-down of all the connections created in the connect function:

await adapter.disconnect();

// Adapter is now disconnected.

Components

The Webex SDK Adapter is meant to be used with Webex Components.

For more information on how to use Webex Components, visit this page.

The following examples display how you can utilize the Webex SDK Adapter along with Webex Components to provide a fully connected component:

React Component With Hooks

Utilizing the useEffect hook, we can connect our adapter in a deferred event after initial render.

import '@webex/components/dist/css/webex-components.css';

import React, {useEffect, useState} from 'react';
import Webex from 'webex';
import WebexSDKAdapter from '@webex/sdk-component-adapter';
import {WebexAvatar, WebexDataProvider} from '@webex/components';

const webex = new Webex({
  credentials: `<YOUR_ACCESS_TOKEN>`,
});
const adapter = new WebexSDKAdapter(webex);

function App() {
  const [adapterConnected, setAdapterConnected] = useState(false);

  useEffect(() => {
    // This is the suggested way to do async hooks.
    // Ref: https://github.com/facebook/react/issues/14326
    async function doConnect() {
      // Wait for the adapter to connect before rendering.
      await adapter.connect();
      setAdapterConnected(true);
    }

    doConnect();

    // On teardown, disconnect the adapter
    return () => {
      adapter.disconnect();
    }
  }, []);


  return (
    <div className="App">
      {
        adapterConnected && (
          <WebexDataProvider adapter={adapter} >
            <WebexAvatar personID="<AVATAR_ID>" />
          </WebexDataProvider>
        )
      }
    </div>
  );
}

export default App;

React Class Component

For traditional React class components, the adapter should connect once the component mounts.

import '@webex/components/dist/webexComponents.css';

import React, { Component } from 'react'
import Webex from 'webex';
import WebexSDKAdapter from '@webex/sdk-component-adapter';
import {WebexAvatar, WebexDataProvider} from '@webex/components';

const credentials = `<YOUR_ACCESS_TOKEN>`;

const webex = new Webex({
  credentials,
});

export default class App extends Component {

  constructor(props) {
    super(props);

    this.state = {
      adapterConnected: false
    };

    this.adapter = new WebexSDKAdapter(webex);
  }

  async componentDidMount() {
    await adapter.connect();
    // Once adapter connects, set our app state to ready.
    this.setState({adapterConnected: true});
  }

  async componentWillUnmount() {
    // On teardown, disconnect the adapter.
    await this.adapter.disconnect();
  }

  render() {
    return (
      <div className="App">
        {
          this.state.adapterConnected && (
            <WebexDataProvider adapter={this.adapter} >
              <WebexAvatar personID="<AVATAR_ID>" />
            </WebexDataProvider>
          )
        }
      </div>
    )
  }
}

Contributing

We'd love for you to contribute to our source code and to make Webex SDK Adapter even better than it is today! Here are some guidelines that we'd like you to follow.

License

MIT License

Support

For more developer resources, tutorials and support, visit the Webex developer portal, https://developer.webex.com.

sdk-component-adapter's People

Contributors

adamweeks avatar akoushke avatar alinasuciu avatar benjamingolya avatar bogdanmaier28 avatar cernaianumihai avatar cipak avatar corodaniel avatar coroiandaniel avatar dependabot[bot] avatar harshrai-11 avatar jdaly13 avatar jonniespratley avatar karinasigartau0798 avatar kesari3008 avatar kponmuth avatar lalli-flores avatar lungancatalin avatar maloun96 avatar patricia0817 avatar rajeshtezu avatar spider-detective avatar taymoork2 avatar thescripted avatar webex-components-publisher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-component-adapter's Issues

Video and audio control issue

Hi,

I'm using WebexMeeting from @webex/components
If user disables video or audio before clicking on Join Meeting button, then these controls won't work after the user joins.
User himself will see that video is being shared or audio is un-muted but rest of the participants (joined using desktop application) can't see the video or hear him (both remain muted).

sample-code.zip

Cannot Create WebEx meeting

Premise:

  • Trying to create a Single page React app
  • used the components defined for Creating and Joining the meeting.
  • Able to connect and authenticate with access token

Issue:

  • when trying to get the meeting created, getting below errors:
index.js:1 Get Meeting error:  Error: Could not find meeting with ID "[email protected]"

MeetingsSDKAdapter.js:587 Uncaught Error: Could not find meeting with ID "[email protected]" to add audio control

and above continues for video, share, remote

On investigation of API, the /people API is returning nothing, while get meeting details does get the meeting details.
https://hydra-a.wbx2.com/v1/people?email=sakhanej%40cisco.webex.com

Need to fix for Node

$  babel-node ./scripts/start.js   
/Users/jspratle/Github/sdk-component-adapter/src/utils.js:128
const isSpeakerSupported = !!document.createElement('audio').setSinkId;
                           ^

ReferenceError: document is not defined
    at Object.<anonymous> (/Users/jspratle/Github/sdk-component-adapter/src/utils.js:119:35)

Need to fix the conditional to handle when running in NodeJS

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.