Code Monkey home page Code Monkey logo

peerjs's Introduction

Deprecated!

We have released a new WebRTC platform, ECLWebRTC, to take the place of SkyWay. SkyWay Beta servers have shut down as of March 22nd 2018 (JST). Please migrate to ECLWebRTC, our new WebRTC Platform.

If you are looking for the repository of ECLWebRTC, please see the new JavaScript SDK.

このレポジトリは、2018年3月22日に提供を終了した旧SkyWayのiOS SDKです。SkyWayを利用する場合には新しいSkyWayをご利用ください。

すでに新しいSkyWayをご利用の方は、新しいJavaScript SDKをご覧ください。

PeerJS: Simple peer-to-peer with WebRTC

PeerJS provides a complete, configurable, and easy-to-use peer-to-peer API built on top of WebRTC, supporting both data channels and media streams.

Notice

This branch is a customized version of PeerJS for NTT Communications's WebRTC platform SkyWay.

Setup

Include the library

<script src="https://skyway.io/dist/0.3/peer.js"></script>

Include with NPM

npm install skyway-peerjs

Create a Peer
Get a free API key. Your id only needs to be unique to the namespace of your API key.

var peer = new Peer('pick-an-id', {key: 'myapikey'}); 
// You can pick your own id or omit the id if you want to get a random one from the server.

Data connections

Connect

var conn = peer.connect('another-peers-id');
conn.on('open', function(){
  conn.send('hi!');
});

Receive

peer.on('connection', function(conn) {
  conn.on('data', function(data){
    // Will print 'hi!'
    console.log(data);
  });
});

Media calls

Call

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
navigator.getUserMedia({video: true, audio: true}, function(stream) {
  var call = peer.call('another-peers-id', stream);
  call.on('stream', function(remoteStream) {
    // Show stream in some <video> element.
  });
}, function(err) {
  console.log('Failed to get local stream' ,err);
});

Answer

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
peer.on('call', function(call) {
  navigator.getUserMedia({video: true, audio: true}, function(stream) {
    call.answer(stream); // Answer the call with an A/V stream.
    call.on('stream', function(remoteStream) {
      // Show stream in some <video> element.
    });
  }, function(err) {
    console.log('Failed to get local stream' ,err);
  });
});

SkyWay Links

PeerJS links

peerjs's People

Contributors

alanmshelly avatar che-burashco avatar creatorrr avatar cvan avatar emersion avatar ericz avatar evandro-zanatta-vindi avatar hansoksendahl avatar hnry avatar iwashi avatar jhamit avatar kensakukomatsu avatar khankuan avatar lmb avatar michelle avatar michelle-stripe avatar patrickjs avatar riosu avatar rocky85 avatar rotsuya avatar sbalko avatar sblaurock avatar sho-y avatar tsu-takahashi avatar unsunghero97 avatar xizhao avatar yemel avatar yusuke84 avatar zag2art avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

peerjs's Issues

Mobile to web video chat

hello I am trying to connect from iOS to web socket using peer js.
This works for only web to web, while setting to iOS to web or web to iOS peer connections is failed.
Is is possible via this script to make connection between web and iOS and make video call?

How to to use websockets only for creating connection?

Is it possibe to use websockets only to create a connection? I want something like a fallback if ever webrtc isn't supported on the client/browser, since websockets are already on the peerjs servers. Also tho I think the peerjs client is tightly coupled with the webrtc function. It would be great just to have this especially safari or ios browsers doesn't support webrtc yet.

I posted this on peerjs-server repo but i didn't get any response...

Closing call or mediaconnection, it won't call close event immediately

I'm having difficulties on switching screen sharing and the default camera. Switching calls thru opening and closing the current call to switch the streams(default camera and screen). Even though I override the close event every time I switch calls assuming that when close event is triggered, the call is already closed and thus I can open a call again, still it won't close as i predicted it would. This is a bit confusing to explain, but my problem is that I would like to open a new media connection after closing the current media connection properly.

利用シーンが限られるReliableモジュールの削除を検討する

そもそも、reliableの使用条件はブラウザがsctpをサポートしていない場合&reliableオプションがtrueの場合なのでChrome,FFの場合はどう頑張っても利用できない。

if (!util.supports.sctp && this.reliable) {
    this._reliable = new Reliable(this._dc, util.debug);
  }

また、new Reliableのところでエラーが発生する。

Uncaught TypeError: object is not a function

Failed to load resource: the server responded with a status of 400 (Bad Request) , could not get id from the server

i developing cross platform application using ionic 3 so when i add localhost as a server hosting my application in api setting dashboard the application get id with no error but when i launch the application in phone i get the error couldn't get the id from the server so i tried to add any string as mentioned in dashboard when developing android or ios application i still get the same error so how i can solve this problem ????

Screen sharing bug

I keep receiving this error whilst trying to do screen sharing with this branch:

iceConnectionState is disconnected, closing connections to xemih

Usually connection is stable for about 5 seconds. Shortly afterwards it cancels the stream.

Peer JS fails to initiate calls with Firefox >=41

Since version 41 Firefox generates a onnegotiationneeded event even for the first offer which gets created. Peerjs fails to detect the "onnegotiationneeded" support properly and therefore if Firefox >= 41 create the initial offer the call fails.

マニュアル表記の改善

この文書はIDのユニーク性が保証されていないものと理解される可能性がある。

このIDを利用してピアを特定するのは推奨しません。なぜならば、このIDはコネクションをブローカ(仲介)するのにのみ使われるように作成されているためです。特定に他の情報を使う場合は、metadataの利用を推奨します。

Websocket sudddenly closes

Currently I'm creating a modification on how to communicate via WebSockets only, using send function of web sockets, encountered Uncaught TypeError: e.error is not a function at WebSocket._socket._socket.onclose. On the original peerjs, there were no error as such since it won't fallback to xhr as what i've seen on skyway modified it on this._socket.onclose event/function.

https://skyway.io/dist/0.3/peer.js

// Fall back to XHR if WS closes
  this._socket.onclose = function(msg) {
      util.error("WS closed with code "+msg.code);
      if(!self.disconnected) {
        self._startXhrStream();
      }
  }

Conflict using window.onbeforeunload

I'm using window.onbeforeunload to open a popup or confirmation alert to leave the web app, I notice that when I run window.onbeforeunload on devtools console, it returns skyway's function, not the function i provided to show and alert. Is there a way to override it?

Unable to display received files in Chrome

The application is requesting files to be received ArrayBuffer format, and manually converting to Blobs.

This results in name and type information being stripped out of the original Blob formatted data, and Chrome displays raw data for each received file instead of rendering each correctly.

  • (Firefox doesn't have this issue as it appears to be smart enough to detect the type of raw data)

This could be fixed by changing the serialization of the file DataConnection to none and modifying the receiving code to simply handle received blobs.

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.