我找到了非常好的项目on 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>
我在与服务器建立连接时收到提醒,但我看不到本地和远程视频。有人可以建议可能出错吗?你能告诉我客户端的例子吗,我找不到它here。
答案 0 :(得分:0)
看起来这是演示应用程序的一个非常旧的版本。正确的链接是: https://github.com/alongubkin/phonertc/tree/master/demo