Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wait for disconnect response before leaving visitor room. #1168

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2302,8 +2302,19 @@ public void roomDestroyed(String reason)
if (chatRoomToLeave != null)
{
ChatRoom finalChatRoom = chatRoomToLeave;
final String finalVnode = vnode;

TaskPools.getIoPool().submit(() ->
{
IQ disconnectResponse
= jicofoServices.getXmppServices().getVisitorsManager().sendIqToComponentAndGetResponse(
roomName,
Collections.singletonList(new DisconnectVnodePacketExtension(finalVnode)));
if (disconnectResponse == null || !disconnectResponse.getType().equals(IQ.Type.result))
{
logger.warn("Error or no response to disconnect request: " + disconnectResponse);
}

try
{
logger.info("Removing visitor chat room");
Expand All @@ -2315,11 +2326,6 @@ public void roomDestroyed(String reason)
}
});

if (vnode != null)
{
jicofoServices.getXmppServices().getVisitorsManager().sendIqToComponent(
roomName, Collections.singletonList(new DisconnectVnodePacketExtension(vnode)));
}
}
}

Expand Down
13 changes: 10 additions & 3 deletions jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/VisitorsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,24 @@ class VisitorsManager(
logger.info("VisitorsComponentManager is now ${if (enabled) "en" else "dis"}abled with address $address")
}

fun sendIqToComponent(roomJid: EntityBareJid, extensions: List<ExtensionElement>) {
private fun createIq(roomJid: EntityBareJid, extensions: List<ExtensionElement>): VisitorsIq {
val address = this.address ?: throw Exception("Component not available.")
val iq = VisitorsIq.Builder(xmppProvider.xmppConnection).apply {
return VisitorsIq.Builder(xmppProvider.xmppConnection).apply {
to(address)
ofType(IQ.Type.get)
room = roomJid
addExtensions(extensions)
}.build()
}

/** Send an IQ, block for response or timeout, return the result. */
fun sendIqToComponentAndGetResponse(roomJid: EntityBareJid, extensions: List<ExtensionElement>): IQ? =
xmppProvider.xmppConnection.sendIqAndGetResponse(createIq(roomJid, extensions))

/** Send an IQ, return immediately. Log an error if there's no response. */
fun sendIqToComponent(roomJid: EntityBareJid, extensions: List<ExtensionElement>) {
TaskPools.ioPool.submit {
val response = xmppProvider.xmppConnection.sendIqAndGetResponse(iq)
val response = sendIqToComponentAndGetResponse(roomJid, extensions)
when {
response == null -> logger.warn("Timeout waiting for VisitorsIq response.")
response.type == IQ.Type.result -> {
Expand Down
Loading