-
-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Hi, I need to create a method that reads messages synchronously and all the logic needs to stay within this method.
I looked for a solution on documents and blogs but with no luck, hope this is the right place.
For login I use loginAndWait, but for messages I have to use EventHandler.
Is there a synchronous method in which I can receive the MessageModules?
Can you give us a sample or an idea on how to do it? something like:
func readAllMessageSync(){
let client = XMPPClient()
client.modulesManager.register(AuthModule())
client.modulesManager.register(StreamFeaturesModule())
client.modulesManager.register(SaslModule())
client.modulesManager.register(ResourceBinderModule())
client.modulesManager.register(SessionEstablishmentModule())
client.modulesManager.register(PresenceModule())
client.modulesManager.register(MessageModule())
client.connectionConfiguration.userJid = BareJID("jidSamle")
client.connectionConfiguration.credentials = .password(password: "jidSamlePass", authenticationName: nil, cache: nil)
try await client.loginAndWait()
let presenceModule: PresenceModule = client.modulesManager.getModule(PresenceModule.ID)!
presenceModule.setPresence(show: Presence.Show.dnd, status: "Do not distrub me!", priority: 2)
try await readIncomingMessage(client)
}
func readIncomingMessage(client: XMPPClient){
//exit if 0 message else get message as MessageModule.MessageReceivedEvent
}
thank you
Luigi
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels