Spark Plug-In - How does MessageListener and messageReceived work?

Hi,

I’m trying to develop a simple Spark Plug-In to enable file sharing and sharing screenshots in our corporate network. Source code can be found here: GitHub - Speedy-Gonzalez/MUCFileUpload

Sharing files via network share works perfect. Now I want to integrate a functionality to automatically insert pictures in a MUC room when the Plug-In recognizes that a picture was uploaded to the network share.

I’m trying to listen for messages that end with JPG, JPEG or PNG (because my send functionality just works like that) and it works quite well. This is the code I use for that functionality MUCFileUpload/MUCFileUpload.java at develop · Speedy-Gonzalez/MUCFileUpload · GitHub :

public void chatRoomOpened(final ChatRoom room) {
String roomId = room.getRoomname();

Log.warning("chatRoomOpened: " + roomId);

if (roomId.indexOf(’/’) == -1) {
decorators.put(roomId, new ChatRoomDecorator(room, url));

if (“groupchat”.equals(room.getChatType().toString())) {

room.addMessageListener(new MessageListener() {

public void messageReceived(ChatRoom room, Message message) {

Path path = Paths.get(message.getBody());

String ext = FilenameUtils.getExtension(path.toString());

if (ext.toUpperCase().equals(“PNG”) || ext.toUpperCase().equals(“JPG”) || ext.toUpperCase().equals(“JPEG”)){

TranscriptWindow transcriptWindow = room.getTranscriptWindow();
transcriptWindow.insertIcon(new ImageIcon(path.toString()));

}
}

public void messageSent(ChatRoom room, Message message) {

}
});

}

}
}

My problem is, that when I integrate this Plug-In into Spark, I can’t see all MUC messages that I receive.

E.g. I can’t see messages like “:D” or “http://…”. Messages with characters like !, :, § are mostly not displayed. Why mostly. Because messages like (yeah I’ve tried some very unlikely messages ) “D:D” are shown correctly, even when a “:” is in the message.

I can’t really explain, why this is happening.

Is my code wrong? Do I implement the “MessageListener” wrong?

Thanks.

Best regards

Speedy

Thanks to this tutorial, I’ve been able to run Spark in debug mode (Tools to debug Spark )

This is the error message I get, when someone is sending me “illegal characters”:

Thanks

Speedy

OMG, solved it by myself. (Was I blind or something). I was missing a catch for the InvalidPathException ^^

Remove messageReceived and messageSent from chatRoomOpend · Speedy-Gonzalez/MUCFileUpload@101b0b1 · GitHub

Now it runs perfect