Send string to XMPP MuC participants without using "Message" object - xmpp

In my current project I want to communicate with people in a XMPP Multi User Chat. But also I need to send data to all participants in the conference, but this data should not be seen as a message.
Is it possible to send data (strings) to all participants in a MuC channel by not using a normal chat message?
I'm using Smack API, and I assume, that all participants use my program.
Thanks in advance!

The solution is to use a normal message (with type="groupchat"), but do not include a <body>.
I do not know how this is done in Smack, or if it is possible (I hope it is). An example message would be:
<message to="room#conference.server" type="groupchat">
<yourdata xmlns="your-xmlns">
<anything-you-want-here/>
</yourdata>
</message>
XMPP clients will ignore this message, as it has no <body> tag.

Related

How to get mucroom offline messages

How to retrieve mucroom offline messages from openfire and any plugin available for this one?
Thank you,
You cannot. Multi User Chat in XMPP is presence based. When you are online you get the message. When you get offline, you leave the room and will not get anymore message until you join the room again by sending a presence message.
Update: With ejabberd 16.09, you can now use MUC/Sub protocol to subscribe to chat rooms. When subscribed, you do not have to join the room again to receive the messages. Protocol is documented here: https://docs.ejabberd.im/developer/xmpp-clients-bots/proposed-extensions/muc-sub/

Whats the best way to extend XMPP Presence stanza

We were using openfire 3.7.1 as our XMPP server, and we wanted to extend the Presence stanza to include some extra information like:
<presence from="you#MyServer.com">
<body>...</body>
<custom_element>
<custom_data/>
</custom_element>
</presence>
Could you please show me some pointers as what would be a better approach to do so? E.g., should I modify or extend some XMPP schema so that openfire will process the above presence packet as usual (currently if I send message like above, openfire seems not taking it as a Presence packet)? And should I create a plugin to intercept all packets so as to process our custom elements?
Thanks in Advance!
This is how it is normally done:
<presence from="you#MyServer.com">
<x xmlms="http://mycompany.com/mycustomnamespace1>
<custom_data/>
</x>
</presence>
Openfire will route such a packet without any problems.
You only need a server plugin when the server has to process any action on this custom elements. When the server should route the presence only to your contacts then nothing is required on the server.

Sending XMPP IM message to a room

I am trying to find out if it's possible to send a XMPP IM message to a room instead of individuals.
Everything you need should be defined in the XEP-0045 extension standard.
For everything else you have to ask more specifically.
Sending message in group and sending individual message is different thing. Both handles in different ways. Although! You can send message in group using your room's object i.e. XMPPRoom (Specifically for iOS Client) as bellow:
[XMPPRoom sendMessage:#"Your Message"];
For more information on XMPP MUC follow XEP-0045 doccument.

Problem creating a chat room with XMPP in an iOS app

I have an iphone app where I want to use chat rooms. I've installed an XMPP server (ejabberd) and downloaded the XMPP framework for iOS from google code (http://code.google.com/p/xmppframework/). The server and client work as expected, since I'm able to log in and send chat messages between two users.
However, when I try to create a chat room using the createOrJoinRoom method of the XMPPRoom class (in XEP-0045), I don't get any reply from the server and the chat room is not created.
I've debugged to see what kind of package is sent to the server and it looks like this:
<presence from="test2#beta.bogus.net/mynick" to="muumit15#conference.beta.bogus.net">
<x xmlns="http://jabber.org/protocol/muc"/>
</presence>
I get no error message back but the chat room (muumit15) is not created. At the same time I can use e.g. Adium client to create a chat room and it succeeds. The server has been configured so that every user has a right to create chat rooms.
Any ideas? I even tried sniffing the TCP/IP traffic sent by the Adium client but that was encrypted/compressed/binary so I couldn't see what kind of packages it is sending.
See section 7.2.2 of XEP-0045, particularly Example 18:
<presence
from='hag66#shakespeare.lit/pda'
to='coven#chat.shakespeare.lit/thirdwitch'>
<x xmlns='http://jabber.org/protocol/muc'/>
</presence>
Note that the to address MUST contain a resource, and yours doesn't. The resource is the string after the /, which is used as your nickname in the room. For more information on the XMPP address format, see RFC 6122.

Does xmpp Resource Change?

I'm writing an app which communicates with clients via XMPP. I want to be able to use the users existing xmpp account (they all have google ID's) but I don't want my messages to appear in their regular IM stream.
I'm thinking that when my client pairs with the server it could use a custom resource id eg Fred.Bloggs#gmail.com/MYCUSTOMID then I can always send messages to that ID with the resource tag.
Is this the best approach, are Resource ID's tied to a specific install of a client or should they change on a per session basis?
Google will modify any resource you give it by adding a random identifier to the end.
If you're writing both the sender and the receiver, try using an XMPP extension:
<message to="fred.bloggs#gmail.com">
<x xmlns='http://my.domain.example.com/my_extension'>stuff</x>
</message>
If you need to be able to tell which of the resources is your client, try XEP-0115.