大佬教程收集整理的这篇文章主要介绍了android janus webrtc ondatachannel未触发,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经让 Janus vIDeoroom 正常工作,现在我想实现 DataChAnnel 在设备之间相互发送消息
当发布者发送配置和订阅者加入时,我已经设置了 data:true
voID sendLocalDescription(BigInteger handlEID,JsONObject sdpObj) {
try {
JsONObject msg = new JsONObject();
JsONObject body = new JsONObject();
body.put(requEST,BodyrequestmessageType.CONfigURE.getType());
body.put(AUdio,options.audio);
body.put(VIDEO,options.vIDeo);
body.put(DATA,truE);
msg.put(JANUS,SendmessageType.messaGE.getType());
msg.put(transaCTION,RandomUtil.randomString());
msg.put(SESSION_ID,sessionID);
msg.put(HANDLE_ID,handlEID);
msg.put(BODY,body);
msg.put(jeSP,sdpObj);
connection.sendmessage(msg.toString());
Log.e(SERVER_TAG,"publisher sendLocalDescription: " + body.toString());
} catch (JsONException E) {
e.printstacktrace();
}
}
这里是给订阅者的
private voID sendSubscribemessage() {
try {
JsONObject object = new JsONObject();
object.put(JANUS,SendmessageType.messaGE.getType());
object.put(PLUGIN,PLUGIN_value);
object.put(transaCTION,RandomUtil.randomString());
object.put(SESSION_ID,sessionID);
object.put(HANDLE_ID,handlEID);
JsONObject body = new JsONObject();
body.put(requEST,BodyrequestmessageType.JOIN.getType());
body.put(PTYPE,PType.SUBSCRIBER.getType());
body.put(ROOM,options.meetNum);
body.put(PIN,options.pin);
body.put(PRIVATE_ID,privatEID);
body.put(Feed,publisherBean.getID());
body.put(DATA,truE);
body.put(OFFER_DATA,truE);
object.put(BODY,body);
connection.sendmessage(object.toString());
if(publisherBean.isSumulcast()){
sendConfigureSimulcastmessage();
}
} catch (JsONException E) {
e.printstacktrace();
}
}
为发布者创建对等连接后,我创建了数据通道:
peerConnection = PCFactoryProxy.instance().createPeerConnection(configuration,this);
dataChAnnel = peerConnection.createDataChAnnel("1",new DataChAnnel.Init());
dataChAnnel.registerObserver(new DataChAnnel.observer() {
@OverrIDe
public voID onBufferedamountChange(long l) {
}
@OverrIDe
public voID onStateChange() {
Log.e(SERVER_TAG,"dataChAnnel state: " + dataChAnnel.state().toString());
}
@OverrIDe
public voID onmessage(DataChAnnel.buffer buffer) {
}
});
但我从未看到 onDataChAnnel 被触发,有人可以帮忙吗?
@OverrIDe
public voID onDataChAnnel(DataChAnnel dataChAnnel) {
LogUtil.e(SERVER_TAG,"PeerConnectionChAnnelV3 -> onDataChAnnel: " + dataChAnnel.label());
this.dataChAnnel = dataChAnnel;
// this.dataChAnnel.registerObserver(this);
// sendDataChAnnelmessage("test");
}
据我所知 DataChAnnel,当 Peer A 已经有数据通道对象时,Peer B 会在 onDataChAnnel 被触发时接收数据通道
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的android janus webrtc ondatachannel未触发全部内容,希望文章能够帮你解决android janus webrtc ondatachannel未触发所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。