Re: Swiften Question about payload parsing

Kevin Smith <[email protected]> Thu, 4 Mar 2021 08:54:04 +0000
Newsgroups gmane.network.jabber.devel
Message-ID <[email protected]>
--===============0716231864==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_161F59CB-12CD-40D0-AAFD-6184D6BDDC83"


--Apple-Mail=_161F59CB-12CD-40D0-AAFD-6184D6BDDC83
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 3 Mar 2021, at 20:12, george b <[email protected]> wrote:
>=20
> Hello everyone
>=20
> Today I have question, specific to Swiften. So maybe Kevin could =
answer this ;-)?
>=20
> My omemo implementation works as expected now. But from an =
architecture or performance point of view, it is not really smart =
implemented.
>=20
> The LurchAdapter Class (which handles all the message parsing and =
forwarding to lurch [1]) catches each incoming Swift::Message stanza. =
This stanza will be serialized to a std::string [2]. Just to be able to =
parse out the <items> or the <encrypted> xml part within a message [3]. =
This part will then be forwarded to lurch, which does the real work on =
it.
>=20
> While this works, especially on an embedded device (mobile phone) this =
has an huge resource impact. I tried to get into swiften in more depth =
and tried to implement a class, derived from Swift::Payload, which =
should do the parsing for the 'items' or 'encrypted' payload part. But I =
don't know how to integrate it in the overall parsing of incoming =
stanzas. My target would be to have it somehow integrated in a derived =
class of Swift::Message which could provide me with=20
> std::string Message::getItems()
> std::string Message::getEncrypted()
>=20
> Any hints on how to do this, or any clever alternatives are =
appreciated :-).

If you want a new payload type in Swiften, the quickest way is to follow =
the dev guide - https://swift.im/swiften/guide/#Section-Extending =
<https://swift.im/swiften/guide/#Section-Extending>

/K=

--Apple-Mail=_161F59CB-12CD-40D0-AAFD-6184D6BDDC83
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D"">On =
3 Mar 2021, at 20:12, george b &lt;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt; wrote:<br =
class=3D""><div><blockquote type=3D"cite" class=3D""><br =
class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" =
class=3D""><div class=3D"">Hello everyone<br class=3D""></div><div =
class=3D""><br class=3D""></div><div class=3D"">Today I have question, =
specific to Swiften. So maybe Kevin could answer this ;-)?<br =
class=3D""></div><div class=3D""><br class=3D""></div><div class=3D"">My =
omemo implementation works as expected now. But from an architecture or =
performance point of view, it is not really smart implemented.</div><div =
class=3D""><br class=3D""></div><div class=3D"">The LurchAdapter Class =
(which handles all the message parsing and forwarding to lurch [1]) =
catches each incoming Swift::Message stanza. This stanza will be =
serialized to a std::string [2]. Just to be able to parse out the =
&lt;items&gt; or the &lt;encrypted&gt; xml part within a message [3]. =
This part will then be forwarded to lurch, which does the real work on =
it.<br class=3D""></div><div class=3D""><br class=3D""></div><div =
class=3D"">While this works, especially on an embedded device (mobile =
phone) this has an huge resource impact. I tried to get into swiften in =
more depth and tried to implement a class, derived from Swift::Payload, =
which should do the parsing for the 'items' or 'encrypted' payload part. =
But I don't know how to integrate it in the overall parsing of incoming =
stanzas. My target would be to have it somehow integrated in a derived =
class of Swift::Message which could provide me with <br =
class=3D""></div><div class=3D"">std::string =
Message::getItems()</div><div class=3D"">std::string =
Message::getEncrypted()<br class=3D""></div><div class=3D""><br =
class=3D""></div><div class=3D"">Any hints on how to do this, or any =
clever alternatives are appreciated :-).<br =
class=3D""></div></div></div></blockquote><br class=3D""></div><div>If =
you want a new payload type in Swiften, the quickest way is to follow =
the dev guide -&nbsp;<a =
href=3D"https://swift.im/swiften/guide/#Section-Extending" =
class=3D"">https://swift.im/swiften/guide/#Section-Extending</a></div><div=
><br class=3D""></div><div>/K</div></body></html>=

--Apple-Mail=_161F59CB-12CD-40D0-AAFD-6184D6BDDC83--

--===============0716231864==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
JDev mailing list
Info: https://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: [email protected]
_______________________________________________

--===============0716231864==--