tigase / halcyon Goto Github PK
View Code? Open in Web Editor NEWKotlin Multiplatform XMPP client library
License: GNU Affero General Public License v3.0
Kotlin Multiplatform XMPP client library
License: GNU Affero General Public License v3.0
I am not sure if this is intentional but I noticed that presence subscription
results in firing ContactChangeStatusEvent
event. This seems not entirely correct, as subscription request does not really change contact status.
I am not even sure if this should trigger PresenceReceivedEvent
as this is really subscription request. Perhaps it would be more efficient to have a separate SubscriptionReuqestEvent
to be triggered for such packets.
First I am logging into the XMPP service.
halcyon.connect()
Then, in the SASL event handler, after successful login I am registering handler for RosterEvent and requesting roster entries:
var rosterModule = halcyon.getModule<RosterModule>(RosterModule.TYPE)!!
halcyon.eventBus.register<RosterEvent>(RosterEvent.TYPE) {
handleRosterEvent(it)
}
rosterModule.rosterGet()
Then, again, in the roter event handler I am attempting to request vCard for each roster item:
fun handleRosterEvent(ev: RosterEvent) {
var nick = if(ev.item.name == null || ev.item.name == "") ev.item.jid.localpart else ev.item.name
if (nick == null || nick == "") nick = ev.item.jid.toString()
val contact = Contact(ev.item.jid.toString(), true, nick)
println("RosterItem added: ${contact.jid}, nickname: '${contact.nickname}'")
// Requesting VCard for the roster item
halcyon.eventBus.register<VCardUpdatedEvent>(VCardUpdatedEvent.TYPE) {
handleVCardEvent(it)
}
var vcardModule = halcyon.getModule<VCardModule>(VCardModule.TYPE)!!
vcardModule.autoRetrieve = true
println("Requesting VCard for ${ev.item.jid}")
vcardModule.retrieveVCard(ev.item.jid)
}
And here is the vCard event handler code:
fun handleVCardEvent(ev: VCardUpdatedEvent) {
println("Received VCard: ${ev.jid.toString()}")
var vCard = ev.vcard
println("VCard: ${vCard.toString()}")
println("VCard nickname: ${vCard?.nickname}")
println("VCard formattedName: ${vCard?.formattedName}")
}
I have about 100 items in the roster which all are received using rosterModule.rosterGet()
method call.
Now, the problem is that I request a vCard for each roster item in the roster event handler but I only receive vcard for the last roster item and I receive this vCard for the last roster item 100 times.
It looks like vCard module sends 100 requests but the argument for all these 100 request is set to the last JID requested.
The README file points users to Tigase's online documentation website for Halcyon documentation. However, the website does not contain any documentation for the library yet.
Right now logs on levels from FINEST to FINE contain entire content of stanzas received. Especially for packets like avatar data it makes it very difficult to read and analyze logs which tend to rapidly grow.
It would be much more useful to limit such a high verbosity to the highest log level - FINEST. Any level below that should only contain most critical parts of the stanza. Maybe just the first level of the XML or maybe 2 levels deep. Just to avoid huge chunks of data in the log files.
I am attempting to retrieve contact's vcard as described in the issue: #6 (comment)
For some vcard request I am getting responses like this:
Request:
<iq to="[email protected]" id="JAiFXty3u8W0209Ro0EEDxvx" type="get">
<vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0"/>
</iq>
Response:
<iq to="[email protected]" xmlns="jabber:client" from="[email protected]" type="error" id="JAiFXty3u8W0209Ro0EEDxvx">
<error type="cancel">
<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>
In the library log I can see that the response was not correctly handler:
[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [FINE] tigase.halcyon.core.connector.WebSocketConnector: Received: <iq to="[email protected]" xmlns="jabber:client" from="[email protected]" type="error" id="JAiFXty3u8W0209Ro0EEDxvx"><error type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [FINEST] tigase.halcyon.core.connector.WebSocketConnector: Received element <iq xmlns="jabber:client" from="[email protected]" to="[email protected]" id="JAiFXty3u8W0209Ro0EEDxvx" type="error"><error type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [FINEST] tigase.halcyon.core.eventbus.EventBus: Firing event ReceivedXMLElementEvent(element=XMLElement[name='iq' hash='929711258']) with 3 handlers
[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [WARNING] tigase.halcyon.core.requests.RequestsManager: Error on processing response
tigase.halcyon.core.xmpp.XMPPException
There is an event fired ReceivedXMLElementEvent
but it is not really useful in the application space. It would be bette to receive an error event in response to the vcard IQRequest.
The example in the README file provides a simple use case using connectAndWait
. It does not, however, provide any details on how to check of the connection was successful or not. How to check and handle connection errors in case, for example if password is incorrect.
There is no documentation or example code on how to retrieve user's roster.
Please add code example on retrieving user's roster as well as other typical XMPP use cases:
Please add BOSH connector.
Hey guys,
first of all thank you for your effort making Kotlin Multiplatform XMPP library. There are not many other solutions available in the area so far ๐
The only one question I have is about iOS support - my vision is Kotlin Multiplatform should be a great alternative to separated Android/iOS development, so iOS support is a must.
If you have any plans/thoughts on this matter - could you please share.
thank you
We require the following, minimum content supported in vCards for contacts:
As for the firstName/lastName I am not sure how related to this is currently supported structuredName
and formattedName
. Maybe this would be enough and we do not need first/last names. I am not sure at this point.
Right now, we have a few events in the RosterModule
for item change (Added, Updated, Removed). However, at the startup time, in GUI it is inefficient to deal individual roster items and updated GUI for each element.
It would be very useful to have a single event handler called once, the entire roster is loaded. Then, in the GUI I can load all roster items and display up to date list.
import halcyon from 'halcyon-core-jsLegacy';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor() {
console.log( halcyon.tigase.halcyon.core.Halcyon())
}
}
Fail ERROR TypeError: this.eventBus is undefined
Library like Smack providing xmpp over websocket support.
Could be nice if halcyon support websocket as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.