Giter Site home page Giter Site logo

Comments (5)

mremond avatar mremond commented on May 19, 2024

@genofire Any opinion on this?
Do you like the prototype API to create packets better ?

from go-xmpp.

genofire avatar genofire commented on May 19, 2024

unnecessary complicated
for me the source code is easier to read, if it is formated like before.

from go-xmpp.

mremond avatar mremond commented on May 19, 2024

Thanks for feedback.
I committed my exploration in that branch: https://github.com/FluuxIO/go-xmpp/tree/builder-exploration/pkg/stanza to give you a better idea.

I feel that at some point the code may be difficult to navigate, with the pure parsing / packet formatting part, being mixed with client, component workflow and connection manager.

Separating the stanza building, marshalling and unmarshalling maybe help structure the code better as it grows (and I did not add test modules for all the structure generation, yet).

I think it should still be possible to use the full expending stanza version as well.

Anyway, still thinking about it, as you find this complicated. Maybe I will end up doing something in between (move to a separate package but remove the builder interface).

I am also afraid that godoc will become unusable if we do no split the XML marshalling / unmarshalling part: https://godoc.org/gosrc.io/xmpp

from go-xmpp.

mremond avatar mremond commented on May 19, 2024

Using pointers, I managed to have a prototype of approach that can further reduce building an IQ with payload, as follows:

iq := stanza.NewIQ(stanza.Attrs{Type: "get", To: "service.localhost", Id: "disco-get-1"})
disco := iq.DiscoInfo()
disco.AddIdentity("Test Component", "gateway", "service")
disco.AddFeatures(stanza.NSDiscoInfo, stanza.NSDiscoItems, "jabber:iq:version", "urn:xmpp:delegation:1")

from go-xmpp.

mremond avatar mremond commented on May 19, 2024

@genofire Several things to note for upgrade:

  1. There is now a stanza package to host parsing and stanza structure. It should help make the project structure more obvious.
  2. On DiscoInfo package, you can have several identities. For future reference, see example 2 in XEP-0030: https://xmpp.org/extensions/xep-0030.html#example-2

Other than that, you are not force to use shortcuts and can keep on relying on building the stanza with structs, as before.

from go-xmpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.