Hi,
I'm a developer who has worked primarily with PHP and JavaScript up to this
point and I'd like to get my feet wet with Python and test-writing. Aioxmpp
seems like a great project in this regard, and I promise I will do my best
to minimize the amount of hand-holding!
I was wondering if the following issue still needs work and/or if anyone is
working on it? I would like to take a stab at it.
https://github.com/horazont/aioxmpp/issues/134
Regards,
Yuri
Hi Konstantin,
On Donnerstag, 5. Juli 2018 08:35:42 CEST you wrote:
> Hi, I want to send message to conference. I have added sender user to
> that conference and trying to send message as usual but JID goes like
> CONF_NAME(a)conference.JABBER_SRV but it doesn't work. I can't find
> anything about conferences in documentation.
Please see the MUC module [1] and the muc_logger.py example [2] for how to use
Multi-User Chats (Conferences).
Since joining a MUC/Conference on a client is a stateful operation, it is a
bit more complex than simply sending a message: the MUC module takes care of
most of that, but in the end there’s still an object which holds the state and
you have to use the send method of that object.
However, depending on your use-case, you might want to go a different route.
For example, if what you are building is a kind of "notification bot" which
rarely sends messages to a MUC and does not need to receive messages, it might
be more wise to look into which features your server offers for that. For
example, prosody has [3] which allows to send messages to MUCs via a Slack-
like HTTP API.
If you give more details on what you’re trying to achieve, I can probably give
you more ideas on how to do that.
Please note, too, that you need to be subscribed to the mailing list in order
to post. You can alternatively also join our MUC at
aioxmpp(a)conference.zombofant.net <xmpp:aioxmpp@conference.zombofant.net?join>.
kind regards & have fun,
Jonas
[1]: https://docs.zombofant.net/aioxmpp/0.9/api/public/muc.html
[2]: https://github.com/horazont/aioxmpp/blob/release-0.9/examples/
muc_logger.py
(Note: I am assuming that you are using the latest release, which is why I
pointed the links to the documentation/example from the latest release. If
you’re using the devel branch, please replace 0.9 with devel in the
documentation link and use the example from the devel branch).
[3]: https://modules.prosody.im/mod_slack_webhooks.html
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hi Adam,
First of all, to post to aioxmpp-devel, you need to be subscribed. As an
administrator, I still got your message, but nobody else got it. Replying to
the list.
On Samstag, 22. Juli 2017 17:01:30 CEST you wrote:
> Is there a way to embed a substanza directly (so as a string with XML tags)
> to the Message and IQ stanzas?
Yes, with some (supported) trickery. See below ...
> I need to stress test an IOT application which communicates with various
> hardware devices, and it would be extremely tedious to define these stanzas
> properly.
>
> (so I don't care about the response, I just want to send a bunch of stuff)
>
In general, it is preferable to define it properly. If there is even a slim
chance that you might need to do proper interaction with the IoT application
at a later point (for example for a server side application or something like
that), you’ll benefit from properly defining the schema.
> An example of what I want to send:
>
> <message id="2190" type="chat"
> to="mzclientxmppapp(a)xmpp-cls.intamac.com/xmppadmin"
> from="84eb18ceb80d(a)xmpp-cls.intamac.com/smarthub" xmlns="jabber:client">
> <alert xmlns="Intamac:alert" id="14147" alert="Car_AlarmEnd" source="aad"
> timestamp="1470013199" /> </message>
aioxmpp supports sending and receiving arbitrary XML trees. You cannot
directly send raw strings of XML, because that would be unsafe (the whole
stream would break if you sent "<test>" without closing tag).
By default, Message stanzas do not support this, but you can monkey patch that
behaviour into it using:
# put these lines somewhere in the start up of your app
import aioxmpp
aioxmpp.Message.raw = aioxmpp.xso.Collector()
(see [1] for details on the Collector descriptor)
Now you can compose your message like this:
import lxml.etree as etree
msg = aioxmpp.Message(
type_=aioxmpp.MessageType.CHAT,
to=aioxmpp.JID.fromstr("mzclientxmppapp(a)xmpp-cls.intamac.com/xmppadmin"),
)
msg.raw.append(etree.fromstring(
'<alert xmlns="Intamac:alert" id="14147" alert="Car_AlarmEnd"'
' source="aad" timestamp="1470013199" />'
))
The Collector-based attribute is a list of ElementTree or Element objects
(from the etree-API). It is normally used as catch-all in situations where it
isn’t known what elements will occur beforehand (for example in PubSub
notifications), but it can also be used to embed arbitrary XML.
I’ve added a send_raw.py example, check it out in the git repository [2].
Have fun!
Jonas
[1]: https://docs.zombofant.net/aioxmpp/devel/api/public/
xso.html#aioxmpp.xso.Collector
[2]: https://github.com/horazont/aioxmpp/blob/devel/examples/send_raw.py
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEG/EPV+Xzd5wEoQQIwGIDJZdiWIoFAll0v80ACgkQwGIDJZdi
WIppMg/+KuHFKrHpkP2VuVxAy0rcurmKfGR53QhPTrJJoIQSjwj2nzZmda/X9boW
3gtHBClWk4IQRRGTc35D7TbsInLQQ5EWuBDB1RDkeuu9kCqPAfiPXtr8/z6PNh6O
AnsmZCZ9ZgbzNNDv0Pr0n+8TOq+U4jV8hEwGbO7xOPDBfLOXGRB5d2WxDBiI8gKV
iQThQZUt43xAX0MIYF5xlCHzyVV8m8KoAb1HU4Up/sqrj0Z8US11yd9IUr2OvD8/
tkCwtjnUmmqrcsPxgBoVFfYvZiRVYkVxMr8mLufFhlL+WDjO8luEr+TGGd2V66nY
oxvyYSvh3vHFgANTUM0VZnW2y6zXcdB6Vf2Gprh1ImE7hrTh8s8tmwhsqWJ37B/9
04JM50JWMJrZXYkRvon0byxsQdiJ7f8jlrY/JUEV8bTb4ysANZmEuflWH1zuuSkv
bcGdjdxGcGE3OneZ3Yr8JfERY905euf3iNS2wFNfo8gO390X9s4C1XNGCfwOMzTj
Us5NaujadcN9hmdcvaZePdq+3HpmyUyHVtLBY/Wiu+1JCu4kI8aFo91mhQfzozLm
jP5fhjmQqzi2I6y+a/ywbbNKXeRozJ7Q7CzSQXH4m7cj+X1gsm//0dGgVeDE/ybn
5eak+5mGST/EG3Jh+fVo+kmF3izk+mFMWUkwzEqSbh51uW1hq8k=
=xrDN
-----END PGP SIGNATURE-----