2

我已经在本地成功测试了 vline-node 示例,但是当我将代码上传到服务器时,我的用户能够呼叫对方,但在另一端用户无法接听任何电话,因为没有接听电话。我正在使用从 GitHub 下载的这个脚本。vline示例中使用的链接

https://github.com/vline/vline-php-example

如果你使用它,请帮助我。谢谢

  var client, vlinesession,
    authToken = '<?php echo $vline->getJWT() ?>',
    serviceId = '<?php echo $vline->getServiceID() ?>',
    profile = {"displayName": '<?php echo $vline->getUserDisplayName() ?>', "id": '<?php echo $vline->getUserID() ?>'};

  // Create vLine client  
  window.vlineClient = client = vline.Client.create({"serviceId": serviceId, "ui": true});
  // Add login event handler
  client.on('login', onLogin);
  // Do login


  client.login(serviceId, profile, authToken);


  function onLogin(event) {
    vlinesession = event.target;
    // Find and init call buttons and init them
    $(".callbutton").each(function(index, element) {
       initCallButton($(this)); 
    });
  }

  // add event handlers for call button
  function initCallButton(button) {
    var userId = button.attr('data-userid');

    // fetch person object associated with username
    vlinesession.getPerson(userId).done(function(person) {
      // update button state with presence
      function onPresenceChange() {
        if(person.getPresenceState() == 'online'){
            button.removeClass().addClass('active');
        }else{
            button.removeClass().addClass('disabled');
        }
        button.attr('data-presence', person.getPresenceState());
      }

      // set current presence
      onPresenceChange();

      // handle presence changes
      person.on('change:presenceState', onPresenceChange);

      // start a call when button is clicked
      button.click(function() {
              if (person.getId() == vlinesession.getLocalPersonId()) {
            alert('You cannot call yourself. Login as another user in an incognito window');
            return;
              }
          if(button.hasClass('active'))
            person.startMedia();
      });
    });

  }

  return client;
})();

$(window).unload(function() {
  vlineClient.logout();
});
</script>`
4

0 回答 0