Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions src/main/java/org/jitsi/impl/protocol/xmpp/ChatRoomImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public class ChatRoomImpl
*/
private Presence lastPresenceSent;

private List<ExtensionElement> initialPresenceExtensions
= new ArrayList<ExtensionElement>();

/**
* Number of members in the chat room. That excludes the focus member.
*/
Expand Down Expand Up @@ -232,6 +235,14 @@ public void joinAs(String nickname)
@Override
public void processPresence(Presence packet)
{
// make sure this is the first presence we send
if (lastPresenceSent == null)
{
initialPresenceExtensions.forEach(e -> {
packet.removeExtension(e);
packet.addExtension(e);
});
}
lastPresenceSent = packet;
}
};
Expand Down Expand Up @@ -1262,6 +1273,12 @@ public void processPresence(Presence presence)
}
}

@Override
public void addInitialPresenceExtensions(ExtensionElement ex)
{
this.initialPresenceExtensions.add(ex);
}

class MemberListener
implements ParticipantStatusListener
{
Expand Down
27 changes: 11 additions & 16 deletions src/main/java/org/jitsi/jicofo/JitsiMeetConferenceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,6 @@ private void joinTheRoom()
services.getJigasiDetector());
transcriberManager.init();

chatRoom.join();

// Advertise shared Etherpad document
meetTools.sendPresenceExtension(
chatRoom, EtherpadPacketExt.forDocumentName(etherpadName));

// Advertise the conference creation time in presence
setConferenceProperty(
ConferenceProperties.KEY_CREATED_MS,
Expand All @@ -590,17 +584,18 @@ private void joinTheRoom()
// Advertise whether octo is enabled/disabled in presence
setConferenceProperty(
ConferenceProperties.KEY_OCTO_ENABLED,
Boolean.toString(config.isOctoEnabled()));
Boolean.toString(config.isOctoEnabled()),
false);

// Trigger focus joined room event
EventAdmin eventAdmin = FocusBundleActivator.getEventAdmin();
if (eventAdmin != null)
{
eventAdmin.postEvent(
EventFactory.focusJoinedRoom(
roomName,
getId()));
}
// let's add all initial extensions before join, so they are added
chatRoom.addInitialPresenceExtensions(
EtherpadPacketExt.forDocumentName(etherpadName));
chatRoom.addInitialPresenceExtensions(
ConferenceProperties.clone(conferenceProperties));
chatRoom.addInitialPresenceExtensions(
VersionBroadcaster.getVersionsExtension(this));

chatRoom.join();
}

/**
Expand Down
114 changes: 12 additions & 102 deletions src/main/java/org/jitsi/jicofo/VersionBroadcaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
import java.util.stream.*;

/**
* The class listens for "focus joined room" and "conference created" events
* and adds the info about all conference components versions to Jicofo's MUC
* Providers info about all conference components versions to Jicofo's MUC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in "Providers"

* presence.
*
* @author Pawel Domas
* @author Damian Minkov
*/
public class VersionBroadcaster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename the class to Versions as it's no longer broadcasting anything?

extends EventHandlerActivator
{
/**
* The logger
Expand All @@ -50,105 +49,16 @@ public class VersionBroadcaster
= Logger.getLogger(VersionBroadcaster.class);

/**
* <tt>FocusManager</tt> instance used to access
* <tt>JitsiMeetConference</tt>.
*/
private FocusManager focusManager;

/**
* <tt>VersionService</tt> which provides Jicofo version.
*/
private VersionService versionService;

/**
* Jitsi Meet tools used to add packet extension to Jicofo presence.
*/
private OperationSetJitsiMeetTools meetTools;

/**
* Creates new instance of <tt>VersionBroadcaster</tt>.
*/
public VersionBroadcaster()
{
super(new String[] {
EventFactory.FOCUS_JOINED_ROOM_TOPIC,
EventFactory.CONFERENCE_ROOM_TOPIC
});
}

/**
* {@inheritDoc}
*/
@Override
public void start(BundleContext bundleContext)
throws Exception
{
focusManager
= ServiceUtils2.getService(bundleContext, FocusManager.class);

Objects.requireNonNull(focusManager, "focusManager");

versionService
= ServiceUtils2.getService(bundleContext, VersionService.class);

Objects.requireNonNull(versionService, "versionService");

meetTools
= focusManager.getOperationSet(OperationSetJitsiMeetTools.class);

Objects.requireNonNull(meetTools, "meetTools");

super.start(bundleContext);
}

/**
* {@inheritDoc}
*/
@Override
public void stop(BundleContext bundleContext)
throws Exception
{
super.stop(bundleContext);

focusManager = null;
versionService = null;
meetTools = null;
}

/**
* Handles {@link EventFactory#FOCUS_JOINED_ROOM_TOPIC} and
* {@link EventFactory#CONFERENCE_ROOM_TOPIC}.
*
* Constructs versions extension to be sent with presence.
* {@inheritDoc}
*/
@Override
public void handleEvent(Event event)
static ComponentVersionsExtension getVersionsExtension(
JitsiMeetConference conference)
{
String topic = event.getTopic();
if (!topic.equals(EventFactory.FOCUS_JOINED_ROOM_TOPIC)
&& !topic.equals(EventFactory.CONFERENCE_ROOM_TOPIC))
{
logger.error("Unexpected event topic: " + topic);
return;
}

EntityBareJid roomJid
= (EntityBareJid)event.getProperty(EventFactory.ROOM_JID_KEY);

JitsiMeetConference conference
= focusManager.getConference(roomJid);
if (conference == null)
{
logger.error("Conference is null");
return;
}

ChatRoom chatRoom = conference.getChatRoom();
if (chatRoom == null)
{
logger.error("Chat room is null");
return;
}
FocusManager focusManager = ServiceUtils2.getService(
FocusBundleActivator.bundleContext, FocusManager.class);
VersionService versionService = ServiceUtils2.getService(
FocusBundleActivator.bundleContext, VersionService.class);

JitsiMeetServices meetServices = focusManager.getJitsiMeetServices();
ComponentVersionsExtension versionsExtension
Expand Down Expand Up @@ -186,9 +96,9 @@ public void handleEvent(Event event)
String.join(",", jvbVersions));
}

meetTools.sendPresenceExtension(chatRoom, versionsExtension);

if (logger.isDebugEnabled())
logger.debug("Sending versions: " + versionsExtension.toXML());
logger.debug("Providing versions: " + versionsExtension.toXML());

return versionsExtension;
}
}
3 changes: 1 addition & 2 deletions src/main/java/org/jitsi/jicofo/osgi/JicofoBundleConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ protected String[][] getBundlesImpl()
},
{
"org/jitsi/jicofo/bridge/JvbDoctor",
"org/jitsi/jicofo/recording/jibri/JibriStats",
"org/jitsi/jicofo/VersionBroadcaster"
"org/jitsi/jicofo/recording/jibri/JibriStats"
},
{
"org/jitsi/jicofo/health/Health"
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jitsi/protocol/xmpp/ChatRoom2.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ void modifyPresence(Collection<ExtensionElement> toRemove,
Collection<ExtensionElement> toAdd);

void setConference(JitsiMeetConference conference);

void addInitialPresenceExtensions(ExtensionElement ex);
}
6 changes: 6 additions & 0 deletions src/test/java/mock/muc/MockMultiUserChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public void setConference(JitsiMeetConference conference)
this.conference = conference;
}

@Override
public void addInitialPresenceExtensions(ExtensionElement ex)
{

}

@Override
public String getName()
{
Expand Down