问题描述
我在会话期间多次一对一地调用客户端,并且在主机上调用了 streamCreated
事件.当我挂断时,我取消订阅,客户端取消发布.但是,当我再次调用客户端时, streamCreated
事件在主机端被调用两次.我多次调用客户端 3、4、5 等,并且 streamCreated
事件触发的次数与我在客户端调用的次数相同.例如,在我第 7 次调用客户端时,streamCreated
被调用了 7 次!尽管 streamDestroyed
被调用,但我似乎并没有真正破坏流.
I'm calling on a client, one-to-one, multiple times during a session and the streamCreated
event gets called on the host. When I hang up, I unsubscribe and the client unpublishes. However, when I call on the client again, the streamCreated
event gets called twice on the host's side. I call on the client 3, 4, 5, etc. more times and the streamCreated
event fires the same number of times as I have called on the client. For example on the 7th time I call the client, streamCreated
gets called 7 times! It seems like I'm not really destroying the streams although streamDestroyed
gets called.
在客户端,我非常绝望地尝试取消发布:
On the client side, I was desperate enough to try and unpublish with:
clientSession.unpublish(clientPublisher, handleError);
clientPublisher.stream.destroy();
clientPublisher.destroy();
clientPublisher = null;
在主机端,我也尝试确保订阅者被销毁:
On the host side, I've also tried to make sure the subscriber was destroyed:
clientSession.unsubscribe(clientSubscriber);
clientSubscriber.destroy();
clientSubscriber = null;
这个问题是当我打开一个带有多个客户端的视频监视器并让每个客户端在没有音频的情况下发布时.但是,我仍然可以听到我呼叫的客户的声音……就像他们的原始流仍然存在一样.我做错了什么?
The problem with this is when I open a video monitor with multiple clients and have each client publish without audio. However, I can still hear the client I called on... like their original stream(s) still exists. What am I doing wrong?
推荐答案
每次我打电话给那个人,我都在使用:
Every time I called on the person, I was using:
clientSession.on('streamCreated', function (event) {
clientSubscriber = clientSession.subscribe(event.stream, vid, {
...
因此,每次我调用客户端时,它都会创建一个新的事件处理程序.为了解决这个问题,我在与客户端断开连接时添加了以下代码.
So, each time I called on a client, it created a new event handler. To correct the issue, I added the following code when I disconnected from the client.
clientSession.unsubscribe(clientSubscriber);
clientSession.off();
这杀死了事件处理程序,现在一切正常.
That killed the event handler and everything works properly now.
这篇关于Tokbox streamCreated 被调用的次数与客户端被调用的次数相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!