作为一个实验,我尝试了一些使用dart和easyrtc的东西。我开始于将this (它通常通过nodejs服务器提供服务,找到了here)移植到dart版本,这就是我从它得到的
编辑:我找出了导致错误的代码部分。它是for循环无法运行的数据对象代理。通常,setRoomOccupantListener函数将房间名称和一个对象作为参数提供,该对象包含所有连接到该房间的对等点。我用普通的javascript制作了一个对象布局的屏幕截图,就像我在chrome中调试时的样子一样,找到了here。
function connect() {
easyrtc.setRoomOccupantListener(convertListToButtons);
}
function convertListToButtons (roomName, data, isPrimary) {
clearConnectList();
var otherClientDiv = document.getElementById("otherClients");
for(var easyrtcid in data) {
var button = document.createElement("button");
button.onclick = function(easyrtcid) {
return function() {
performCall(easyrtcid);
};
}(easyrtcid);
var label = document.createTextNode(easyrtc.idToName(easyrtcid));
button.appendChild(label);
otherClientDiv.appendChild(button);
}
}here是我在chromium中调试dart代码时的屏幕截图
void connect() {
easyrtc.setRoomOccupantListener(convertListToButtons);
}
void convertListToButtons(roomName, data, isPrimary) {
clearConnectList();
var otherClientDiv = querySelector("#otherClients");
for (var easyrtcid in data) {
var button = document.createElement("button");
button.onClick.listen((event) {
performCall(easyrtcid);
});
button.appendText(easyrtc.idToName(easyrtcid));
otherClientDiv.append(button);
}
}这是我得到的错误:
Class 'Proxy' has no instance getter 'iterator'.
NoSuchMethodError: method not found: 'iterator' Receiver: Instance of 'Proxy' Arguments: []
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1 P...<omitted>...7)我是不是遗漏了一些简单的东西,或者这是某种不兼容?谢谢。
发布于 2014-05-18 20:59:16
我知道你也可以使用 import package:js/js.dart'; 。我不知道怎么用
你可以试一试
import 'dart:js' as js;https://www.dartlang.org/articles/js-dart-interop/
这看起来也很奇怪
easyrtc = js.context.easyrtc; // <== here you have context 'easyrtc'
easyrtc.easyApp('easyrtc.audioVideo', 'selfVideo', new js.JsObject.jsify(['callerVideo']), loginSuccess, loginFailure);
// and here again 'easyrtc.audioVideo', I guess this is one to much试一试
easyrtc.easyApp.callMethod('audioVideo', ['selfVideo', js.JsObject.jsify(['callerVideo']), loginSuccess, loginFailure]); 其中'audioVideo‘是被调用的方法,其余是参数
easyrtc.callMethod('easyApp', ['audioVideo', 'selfVideo', js.JsObject.jsify(['callerVideo']), loginSuccess, loginFailure]); 其中'easyApp‘是被调用的方法,其余是参数。
如果你可以在JavaScript中添加代码的外观,我就可以创建更好的示例。
发布于 2014-05-19 03:53:03
像dart:js一样,package:js不直接处理Dart列表。因此,下面这行代码:
easyrtc.easyApp('easyrtc.audioVideo', 'selfVideo',
['callerVideo'], loginSuccess, loginFailure);应该是:
easyrtc.easyApp('easyrtc.audioVideo', 'selfVideo',
js.array(['callerVideo']), loginSuccess, loginFailure);https://stackoverflow.com/questions/23722154
复制相似问题