Giter VIP home page Giter VIP logo

sdkjs's Introduction

Description

Javascript SDK for Snowem service. For more detail, please check here.

SDK Loading and Initialization

The following snippet will load SnowSDK javascript. If you host your snowsdk.js yourself, change the path to it accordingly.

(function(d){
  var js, id = 'snowsdk', ref = d.getElementsByTagName('script')[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement('script'); js.id = id; js.async = true;
  js.src = "<path-to>/snowsdk.js";
  ref.parentNode.insertBefore(js, ref);
}(document));

window.snowAsyncInit = function() {
   var config = { 
      'ip': "your-wss-ip",
      'port': 443 
   };  
   SnowSDK.init(config);

   //start your code here
   console.log("start your app here");
   start_app();
}

When SnowSDK is loaded, it invokes snowAsyncInit if it is defined. Once it is called, you can initlialize SnowSDK with init function. The init function requires domain name or ip address of Snowem Websocket Service.

Example Usage

Create Peer Agent

var config = {
   'wss_ip': "snowem.example.com",
   'wss_port': 443,
}
var peer = new SnowSDK.PeerAgent(config);

Publish A Stream

var settings = { 
   'channelid': peer.channelId, 
   'local_video_elm': document.getElementById('localVideo')
};  
peer.onAddPeerStream = function(info) {
  console.log("peerid: ", info.peerid);
  //make use of remote stream
  //remote_video_elm.srcObject = info.stream;
}
peer.onRemovePeerStream = function(info) {
  console.log("removing stream from peerid: " + info.peerid);
}
peer.publish(settings);

Play A Stream

var config = { 
   'channelid': peer.channelId,
   'remote_video_elm': document.getElementById('remoteVideo')
};  
peer.onAddPeerStream = function(info) {
  console.log("peerid: ", info.peerid);
  //make use of remote stream
  //remote_video_elm.srcObject = info.stream;
}
peer.onRemovePeerStream = function(info) {
  console.log("removing stream from peerid: " + info.peerid);
}
peer.play(config);

sdkjs's People

Contributors

jackiedinh38 avatar jackiedinh8 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.