0

我在 Github 上找到了非常好的项目,但我无法全部理解。

我安装了一个信号服务器(socket.io)和一个转向服务器。我正在尝试为 IOS 制作一个应用程序,我正在使用如下代码:

<video height="300" id="localVideo"></video>
<video id="remotesVideos"></video>

<script type="text/javascript">
  document.addEventListener("deviceready", onDeviceReady, false);

  function onDeviceReady() {
    var phonertc = cordova.require('com.dooble.phonertc.PhoneRTC');
    var socket = io('http://mysait.com:3000');

    socket.on("connect", function() {
      socket.emit("join", "myroom");
      socket.on("message", function(message) {
        console.log("GOT MESSAGE:");
        message.payload.sdp = message.payload.sdp.replace(/(\r\n|\n|\r)/gm,"");

        // when a message is received from the signaling server,
        // notify the PhoneRTC plugin.
        phonertc.receiveMessage(message.payload);
      });
    });

    socket.on('connect',function() {
      alert ('is connect!');
    });

    phonertc.call({
      isInitator: true, // Caller or callee?
      turn: {
        host: 'turn:mysait.com:3478',
        username: 'test',
        password: 'test'
      },
      sendMessageCallback: function (data) {
        // PhoneRTC wants to send a message to your target, use
        // your signaling server here to send the message.
        console.log(data);
        socket.emit("message", data);
      },
      answerCallback: function () {
        alert('Callee answered!');
      },
      disconnectCallback: function () {
        alert('Call disconnected!');
      },
      video: {  // Remove this property if you don't want video chat
        localVideo: document.getElementById('localVideo'),
        remoteVideo: document.getElementById('remoteVideo')
      }
    });
  }
</script>

连接到服务器时我收到警报,但看不到本地和远程视频。有人可以建议可能出了什么问题吗?你能把客户端的例子发给我吗,我在这里找不到。

4

1 回答 1

0

看起来这是演示应用程序的一个非常旧的版本。正确的链接是: https ://github.com/alongubkin/phonertc/tree/master/demo

于 2014-10-16T18:15:49.580 回答