【问题标题】:How to send confirmation messages between clients - PeerJS如何在客户端之间发送确认消息 - PeerJS
【发布时间】:2018-02-18 13:49:39
【问题描述】:

我正在使用PeerJS 在客户端之间进行音频通话,它可以正常工作。我正在向使用两个按钮(接听和拒绝)接听电话的用户显示一个对话框。如下图:

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
  peer.on('call', function(call) {
   // sweetAlert("BINGO")

   bootbox.dialog({
     className: "modal-danger nonumpad",
     closeButton: false,
     animate: true,
     title: 'Call Recieved',
     message: "Accept or Decline",
     onEscape: null,
     buttons: {
      pickup: {
       label: "<i class=\"fa fa-phone\"></i> Answer",
       className: "btn-warning btn-lg pull-left",
       callback: function(){
       return false
      }      
    },
    hangup: {
      label: "<i class=\"fa fa-phone\"></i> Decline",
      className: "btn-warning btn-lg pull-left",
      callback: function(){
        return false;
      }
    }
  }
});





});

我的问题是,我怎样才能将操作发送给其他用户(打电话的人)?

原因是因为我想在接收者按下“接听”时显示计时器或显示对话框以通知呼叫者接收者已按下拒​​绝

【问题讨论】:

    标签: meteor webrtc peerjs


    【解决方案1】:

    来自PeerJS documentation:

    数据连接

    连接

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

    接收

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

    您可以通过call.peer获取发起呼叫的对端ID,然后打开数据连接向呼叫者发送消息('accept'、'decline'等)

    【讨论】:

      猜你喜欢
      • 2020-12-18
      • 2012-03-06
      • 2023-01-07
      • 1970-01-01
      • 2020-09-12
      • 1970-01-01
      • 2022-11-29
      • 2010-11-09
      • 2014-02-28
      相关资源
      最近更新 更多