Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
Stei #1
Member since Oct 2016 · 31 posts
Group memberships: Members
Show profile · Link to this post
Subject: Letting subscribers know you updated your vcard
I'm trying to understand VCards a bit better by reading this page: http://xmpp.org/extensions/xep-0153.html

But i'm having a problem with example 3 on that page.

First of all, here is what I've done:

Example 1, publish avatar data to vcard:
  1. var viq = new VcardIq { Type = IqType.Set };
  2.  
  3. viq.From = myBareJid;
  4. viq.Vcard.Photo = new Matrix.Xmpp.Vcard.Photo(imageByteArray, Matrix.Xmpp.Vcard.ImageFormat.Jpeg);
  5.  
  6. var iq = await _xmppClient.IqFilter.SendIqAsync(viq);

In example 2, the server should respond with a result.

Example 3, including avatar hash in presence data. How do I do this? The parameters in _xmppClient.SendPresence() only allow for Show, status, and priority. How do I include the photo hash, as well as the
<x xmlns='vcard-temp:x:update'></x>
tags?

Here is the example that is shown in the guide of what I'm needing to send:
  1. <presence from='juliet@capulet.com/balcony'>
  2.  <x xmlns='vcard-temp:x:update'>
  3.     <photo>sha1-hash-of-image</photo>
  4.  </x>
  5. </presence>

Or am I going about this the wrong way? Do I need to manually send the Presence that includes the avatar hash?
This post was edited on 2016-11-08, 11:33 by Alex.
Edit reason: added code formatting for c# and xml
Avatar
Alex #2
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There is an event called OnBeforeSendPresence. This event fores before MatriX sends out the presence to the server. This is a good place to inject photo hash and makes sure it gets sent which each outgoing presence.

example:
  1. private void xmppClient_OnBeforeSendPresence(object sender, PresenceEventArgs e)
  2. {
  3.     e.Presence.Add(new Matrix.Xmpp.Vcard.Update.X("Your-photo-hash"));
  4. }

Clients which show avatars cache the images including the Hash. With vcard presence extension they know exactly when a contact changed an avatar and only then fetch the new vcard.

Alex
Avatar
Stei #3
Member since Oct 2016 · 31 posts
Group memberships: Members
Show profile · Link to this post
Quote by Alex:
There is an event called OnBeforeSendPresence. This event fores before MatriX sends out the presence to the server. This is a good place to inject photo hash and makes sure it gets sent which each outgoing presence.

example:
  1. private void xmppClient_OnBeforeSendPresence(object sender, PresenceEventArgs e)
  2. {
  3.     e.Presence.Add(new Matrix.Xmpp.Vcard.Update.X("Your-photo-hash"));
  4. }

Clients which show avatars cache the images including the Hash. With vcard presence extension they know exactly when a contact changed an avatar and only then fetch the new vcard.

Alex

Great, thank you for the help. Just what I needed
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS