天道酬勤,学无止境

peerjs

直接从冷启动弹出状态(Pop up state directly from coldstart)

问题 我使用 ionic 框架构建了一个 Cordova 应用程序。 它是使用 Peer JS 构建的,每当我的对等方接到来电时,我需要应用程序从冷启动快速打开一个状态,有点像电话应用程序在我们接到电话时打开来电活动。 目前我正在使用离子推送通知来打开单击通知的状态,但这需要很长时间并且从启动屏幕开始加载。 有没有办法将包含接收呼叫代码的状态快速弹出到前台 回答1 对于 Cordova,我想出的技巧是, 首先,将来电代码分离成一个带有所需javascript代码的html页面。 接下来,发送带有特定有效负载的通知,然后在 phonegap 推送插件的 onRecieve 方法中,我检查有效负载,如果它与特定有效负载匹配并且如果应用程序被终止,我使用意图打开包含的主要活动cordova webview,我根据意图在这里加载了html页面。 这使它看起来好像应用程序“弹出打开”。

2022-01-15 23:26:25    分类:技术分享    android   performance   ionic-framework   webrtc   peerjs

Pop up state directly from coldstart

I've built a Cordova app using the ionic framework. It is build using Peer JS and i need the app to open a state from cold start quickly whenever my peer receives an incoming call, kind of like the phone app opens the incoming call activity when we receive a call. Currently I'm using ionic push notifications to open the state on click of the notification but that takes too long and loads from the splash screen onwards. Is there a way to kind of pop open my state containing the receive call code into the foreground quickly

2022-01-15 20:43:37    分类:问答    android   performance   ionic-framework   webrtc   peerjs

在服务器端断开对等点与 PeerJS 的连接(Disconnect a peer from PeerJS, on the server side)

问题 我有这样的场景: Peer 必须先进行身份验证,然后才能使用 peerjs 服务。 服务器等待对等方发送身份验证的 x 时间。 对等点不会在 x 时间内发送身份验证,因此服务器强制断开对等点的连接(必须是可能的,因为客户端断开连接时服务器默认重启) peerjs 服务器有办法做到这一点吗? 回答1 TL;DR你不能通过他们的 API。 但是,你可以做一些工作! 通过阅读他们的来源,我能够创建他们断开连接的“模拟”。 然而,这并不能提供理由。 它仍然可以满足我的需求! console.log('disconnect peer', id); this._clients['peerjs'][id].socket.close(); this._ips[this._clients['peerjs'][id].ip]--; delete this._clients['peerjs'][id]; this.emit('disconnect', id);

2022-01-13 08:08:37    分类:技术分享    peerjs

Disconnect a peer from PeerJS, on the server side

I have a scenario like this: Peer has to authenticate before it can use the peerjs service. Server waits x amount of time for the peer to send auth. Peer doesn't send auth in x amount of time, so server forcefully disconnects the peer (Must be possible because server restart defaults in clients being disconnected) Does the peerjs server have a way of doing this?

2022-01-11 11:06:54    分类:问答    peerjs

How can I receive data with a peerJS peer to peer connection?

I'm trying to connect two peers using peerJS. I am pretty much just following through their "Getting Started" but I am still struggling. Below is the code that I have gotten so far. <body> <script src="http://cdn.peerjs.com/0.3/peer.min.js"></script> <script> var conn; var peer = new Peer({key: 'lwjd5qra8257b9'}); peer.on('open', function(id){ console.log('My peer ID is:' + id); document.getElementById('peerIdDisplay').innerHTML = '<b>My peer ID is: </b><font color="red">' + id + '</font>'; }); function ConnectToPeer() { var peerId = document.getElementById("peerIdTxtBox").value; console.log

2022-01-10 19:27:30    分类:问答    javascript   html   p2p   peerjs

有多个同行 PeerJS?(Having multiple peers PeerJS?)

问题 这是我与 PeerJS 连接的代码: var peer = new Peer({ key: '[PeerJSID]', debug: 3}); peer.on('open', function(){ $('#my-id').text(peer.id); }); // Receiving a call peer.on('call', function(call){ // Answer the call automatically (instead of prompting user) for demo purposes call.answer(window.localStream); step3(call); }); peer.on('error', function(err){ alert(err.message); // Return to step 2 if error occurs step2(); }); // Click handlers setup $(function(){ $('#make-call').click(function(){ // Initiate a call! var call = peer.call($('#callto-id').val(), window.localStream); step3(call); }); $('#end

2021-12-22 11:19:36    分类:技术分享    javascript   audio   peerjs

iceConnectionState 已断开连接(通过 Internet 使用时)(iceConnectionState is disconnected (when used over the internet))

问题 这个问题以前有人问过,但我还没有找到答案。 我基本上遇到了与此处和此处描述的相同的问题。 我正在尝试使用 PeerJS 设置 webRTC 连接。 它在 LAN 中完美运行,但我无法让它在 Internet 上运行。 我使用 coturn 作为 TURN 服务器,但到目前为止这还没有解决问题。 Chromium 控制台打印出以下内容: PeerJS: Added ICE candidate for: client1 peer.js:1476 PeerJS: Set remoteDescription: ANSWER for: client1 peer.js:1476 PeerJS: Set remoteDescription: OFFER for: client1 peer.js:1476 PeerJS: Set remoteDescription: ANSWER for: client1 peer.js:1476 PeerJS: Received remote stream peer.js:1476 PeerJS: Receiving stream MediaStream peer.js:1476 PeerJS: Created answer. peer.js:1476 PeerJS: Set localDescription: answer for: client1

2021-12-21 15:53:53    分类:技术分享    javascript   webrtc   peerjs   coturn

PeerJS 设置自己的 PeerID(PeerJS Set your own PeerID)

问题 我正在试用 PeerJS 并且效果很好。 只需查看演示,Peer ID 就会自动为您创建。 有没有办法定义/设置你自己的 Peer Id? 回答1 创建对等对象时提供对等 ID: 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. 这就是您在Create a peer下链接到的页面。

2021-12-21 00:25:27    分类:技术分享    javascript   peerjs

Having multiple peers PeerJS?

Here is my code for connections with PeerJS: var peer = new Peer({ key: '[PeerJSID]', debug: 3}); peer.on('open', function(){ $('#my-id').text(peer.id); }); // Receiving a call peer.on('call', function(call){ // Answer the call automatically (instead of prompting user) for demo purposes call.answer(window.localStream); step3(call); }); peer.on('error', function(err){ alert(err.message); // Return to step 2 if error occurs step2(); }); // Click handlers setup $(function(){ $('#make-call').click(function(){ // Initiate a call! var call = peer.call($('#callto-id').val(), window.localStream)

2021-12-20 15:42:20    分类:问答    javascript   audio   peerjs

PeerJS Set your own PeerID

I am trying out PeerJS and it works great. Just looking at the demo's the Peer ID is auto created for you. Is there a way to define / set your own Peer Id?

2021-12-11 18:40:22    分类:问答    javascript   peerjs