[jdev] Echo outgoing chat messages back to myself

4 views
Skip to first unread message

Daniel Dormont

unread,
Jan 4, 2012, 3:00:11 PM1/4/12
to Jabber/XMPP software development list
Hi XMPP-ers,

I've noticed that certain clients (Gmail's web interface most notably) automatically replicate my chat conversations in all windows I have open. I'm wondering how to implement something similar using an XMPP client and server. I control both client and server but don't want to make too many custom modifications if I can help it. As a first step, the easiest thing seems to be to send all messages to a bare JID rather than full JID. From the user's standpoint this correctly causes all messages they receive to appear everywhere.

But what about sent messages? Is there a simple way to have messages I (as a user) send echoed back to my other connected resources? Or should I just send a second message to my own bare JID with some sort of custom element that indicates it was really a message to someone else (and who that someone else is)?

thanks,
Dan

Alexey Nezhdanov

unread,
Jan 5, 2012, 8:59:57 AM1/5/12
to Jabber/XMPP software development list

Just send stanza as is, no?
You don't need any custom elements, all data is already there.

_______________________________________________
JDev mailing list
Info: http://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: JDev-uns...@jabber.org
_______________________________________________

Kevin Smith

unread,
Jan 5, 2012, 9:18:08 AM1/5/12
to Jabber/XMPP software development list
On Wed, Jan 4, 2012 at 8:00 PM, Daniel Dormont <d...@greywallsoftware.com> wrote:
> But what about sent messages? Is there a simple way to have messages I (as a
> user) send echoed back to my other connected resources? Or should I just
> send a second message to my own bare JID with some sort of custom element
> that indicates it was really a message to someone else (and who that someone
> else is)?

Message Carbons - http://xmpp.org/extensions/xep-0280.html - are a way
of having all available resources notified of all incoming and
outgoing messages. I don't know how extensive support for this is yet.

/K

Daniel Dormont

unread,
Jan 5, 2012, 10:56:00 AM1/5/12
to Jabber/XMPP software development list
Hmmm...I'm not seeing how that would work. Suppose user1@mydomain/resource1a sends

<message type="chat" to="user2@mydomain"><body>hello user2</body></message>

Now, in order to make sure user1@mydomain/resource1b also sees the message, the original sender sends what? I was thinking something along the lines of:

<message type="echo" to="user1@mydomain"><body>hello user2</body><original-recipient>user2@mydomain</original-recipient></message>

Without that extra element, how's user1@mydomain/resource1b supposed to know who they're chatting with?

Dan

PS I just also discovered XEP-0033. I will see if I can use that. Ejabberd definitely does not support XEP-0280.

Alexey Nezhdanov

unread,
Jan 5, 2012, 12:44:23 PM1/5/12
to Jabber/XMPP software development list
Ok, let me be more verbose:

user1/resource1 sends the message:
<message to='user2' type='chat'><body>blah</body></body></message>

user1/resource2 gets the notification:
<message to='user2' type='chat'><body>blah</body></body></message>
You do not need to look for differences b/w these two - they are
identical. Or, to be a bit more proactive, you can actually add a
'from' field - i.e. send message to second resource not 'as it was
received [from user1]' but 'as it was sent [to user2]'.

You are stumbled upon the false idea that recipient MUST see his
address in the 'to' field. He needs that not, check how email (Cc:)
works.

On the other hand, if there is already XEP for this exact purpose, you
probably much better off following it - it will provide compartibility
with future clients, you will be among first adopters and your
client/server will be used as a reference implementation.

Daniel Dormont

unread,
Jan 5, 2012, 12:51:22 PM1/5/12
to Jabber/XMPP software development list
I see ... you're suggesting I add logic on the server side to echo the packet without modification. Interesting idea. I can try to write something for that. It might not be all that hard, actually.

dan

Kevin Smith

unread,
Jan 5, 2012, 12:54:29 PM1/5/12
to Jabber/XMPP software development list
On Thu, Jan 5, 2012 at 5:51 PM, Daniel Dormont <d...@greywallsoftware.com> wrote:
> I see ... you're suggesting I add logic on the server side to echo the
> packet without modification. Interesting idea. I can try to write something
> for that. It might not be all that hard, actually.

If you're going to be writing new code for the server, much better to
implement this the Right way and do Carbons, surely?

Sending stanzas with the wrong to= is very much not the appropriate
thing to be doing here.

/K

Matthew Miller

unread,
Jan 5, 2012, 12:55:50 PM1/5/12
to Jabber/XMPP software development list
If you're going to modify the server, why not implement XEP-0280? There are some minor changes that will be happening within the next few days (see standards@ for a discussion on what might change), but don't let that stop you!


- m&m
<http://goo.gl/LK55L>

Daniel Dormont

unread,
Jan 5, 2012, 2:10:45 PM1/5/12
to Jabber/XMPP software development list
Fair enough. I'll read XEP-0280 more closely and see what I can do. If it works out I'll post it to the Ejabberd list. 

Thanks for the tips.

dan
Reply all
Reply to author
Forward
0 new messages