You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem with…
I created a group chat with reference to the instance of tigase-tts-ng,and send messages to groups through users1,all group members can receive messages,But I don't know how to send a message to group members after processing the message in the plugin,please give me some examples,thank you
@Test(groups = {"Multi User Chat"}, description = "#8660: Delivery presence from offline user")
public void testOfflineUserSendsMessage() throws JaxmppException, InterruptedException {
user1Jaxmpp.getEventBus()
.addHandler(MucModule.MucMessageReceivedHandler.MucMessageReceivedEvent.class,
(sessionObject, message, room, nickname, timestamp) -> {
try {
mutex.notify("recv1:" + message.getBody());
} catch (XMLException e) {
Assert.fail(e.getMessage());
}
});
final String mid = nextRnd();
Element msg = ElementBuilder.create("message")
.setAttribute("type", "groupchat")
.setAttribute("to", roomJID.toString())
.child("body")
.setValue("test-" + mid)
.getElement();
user2Jaxmpp.send(Stanza.create(msg));
mutex.waitFor(20_000, "recv1:test-" + mid);
assertTrue(mutex.isItemNotified("recv1:test-" + mid),
"User1 did not received message from offline user");
}
//Here is the code snippet to simulate a group chat
user1Jaxmpp.getEventBus()
.addHandler(MucModule.MucMessageReceivedHandler.MucMessageReceivedEvent.class, new MucModule.MucMessageReceivedHandler() {
@Override
public void onMucMessageReceived(SessionObject sessionObject, Message message, Room room, String s, Date date) {
try {
System.out.println("user1:"+message.getBody());
} catch (Exception e) {
e.printStackTrace();
}
}
});
user2Jaxmpp.getEventBus()
.addHandler(MucModule.MucMessageReceivedHandler.MucMessageReceivedEvent.class, new MucModule.MucMessageReceivedHandler() {
@Override
public void onMucMessageReceived(SessionObject sessionObject, Message message, Room room, String s, Date date) {
try {
System.out.println("user2:"+message.getBody());
} catch (Exception e) {
e.printStackTrace();
}
}
});
user3Jaxmpp.getEventBus()
.addHandler(MucModule.MucMessageReceivedHandler.MucMessageReceivedEvent.class, new MucModule.MucMessageReceivedHandler() {
@Override
public void onMucMessageReceived(SessionObject sessionObject, Message message, Room room, String s, Date date) {
try {
System.out.println("user3:"+message.getBody());
} catch (Exception e) {
e.printStackTrace();
}
}
});
Details (please complete the following information):
Tigase version: [e.g. 8.1.0]
JVM flavour and version [e.g. AdoptOpenJDK11]
Operating system/distribution/version [e.g. Linux Ubuntu 20.04]
The text was updated successfully, but these errors were encountered:
ok,I customized a tigase plugin to process messages sent by group chat member,But I don't know how to notify all group members after processing the message,Below is a custom plugin
@Id(Solitaire.XMLNS_SOLITAIRE_DATA)
@Handles({@Handle(path = {"iq", "query"}, xmlns = Solitaire.XMLNS_SOLITAIRE_DATA)})
@Bean(name = Solitaire.XMLNS_SOLITAIRE_DATA, parent = SessionManager.class, active = true)
publicclassSolitaireextendsAnnotatedXMPPProcessorimplementsXMPPProcessorIfc {
publicstaticfinalStringXMLNS_SOLITAIRE_DATA = "test:group-chat";
privatestaticfinalLoggerlog = Logger.getLogger(Solitaire.class.getName());
@Overridepublicvoidprocess(Packetpacket, XMPPResourceConnectionsession, NonAuthUserRepositoryrepo, Queue<Packet> results,
Map<String, Object> settings) throwsXMPPException {
if (session == null || !session.isAuthorized()) {
return;
}
if (StanzaType.get != packet.getType()) {
return;
}
try {
Elementquery = packet.getElemChild("query");
//Referring to the tigase example I know how to return the result to a single person,but I do not know how to notify //group members after processing messages here
} catch (Exceptione) {
LogUtils.logExeption(log, e);
}
}
}
I have a problem with…
I created a group chat with reference to the instance of tigase-tts-ng,and send messages to groups through users1,all group members can receive messages,But I don't know how to send a message to group members after processing the message in the plugin,please give me some examples,thank you
Details (please complete the following information):
The text was updated successfully, but these errors were encountered: