Adding my own fields to the roster for my users?

I’d like to add user preferences in a way that the preferences show up in every buddy’s roster. I’d also like the preference to persist, so that the result of the next login retrieves the data too.

How can I extend the VCard or a RosterExtension in a way that would let me save some extra data (in this case the URL of an animation that would show for that user on every client that’s chatting with that user.)

Thanks!

I’ve started using:

privateDataManager.setPrivateData

it’s the only way that I’ve found to store some extra data that I can retrieve for each user later on… I’m using the JID as the key to the private data… so I can have one per roster item.

Please let me know if there’s a better way

The only problem is when I try to do anything with the private data manager… I get:

Error: Error #2002: Operation attempted on invalid socket.

at flash.net::XMLSocket/send()

at org.jivesoftware.xiff.core::XMPPConnection/sendXML()[/Users/jimc/prj/sparkweb/s parkweb/xiff/src/org/jivesoftware/xiff/core/XMPPConnection.as:772]

at org.jivesoftware.xiff.core::XMPPConnection/sendKeepAlive()[/Users/jimc/prj/spar kweb/sparkweb/xiff/src/org/jivesoftware/xiff/core/XMPPConnection.as:317]

at com.jivesoftware.spark.managers::ConnectionManager/checkKeepAlive()[/Users/jimc /prj/sparkweb/sparkweb/SparkWebCore/com/jivesoftware/spark/managers/ConnectionMa nager.as:98]

at flash.utils::Timer/_timerDispatch()

at flash.utils::Timer/tick()

What do I have to do to initialize my connection?

I am chatting with this connection, so it has to be a good connection in some ways…

Ok, the above problems were because I had bad characters in my elementName. I could tell because of the openfire error log was showing XML parsing errors.

Now, I seem to be saving private data without errors… but when I try to get private data I get error codes in the resulting XMPPStanza that says ‘Excepton thrown by getter’ typeError: Error #1009: Cannot access a property or method of a null object reference.

Anyone?

That’s equivalent to Java’s NullPointerException. Check what in XMPPStanza is null that shouldn’t be and it may give you a clue what’s going on.

Hi Dave,

Thanks for the help… I realize something’s null. I was hoping to get the data back that I had sent in the past. I’m gonna give it another try today, and take notes here in case they help anyone help me.

I’ve verified in the openfire admin interface that I have Private Data enabled set to true.

So First, I save the data I’m interested in… when the user chooses a different avatar to represent themselves I create my payload which looks like:

public class AChosenAvatar implements IPrivatePayload
{
private var kAvatarName:String;
private var kAvatarURL:String;

public function get avatarName():String {
return kAvatarName;
}

public function set avatarName(name:String):void {
kAvatarName = name;
}

I use the following to send this payload to Openfire:

var key:String = “chosenAvatarFor” + kLocalJID.bareJid.node;
var payload:data.AChosenAvatar = new data.AChosenAvatar();
payload.avatarName = avatarSelector.selectedItem.name;
payload.avatarURL = avatarSelector.selectedItem.avatarURL;
SparkManager.privateDataManager.setPrivateData(key, “projectname”, payload);

And I don’t get any errors there…

How do I verify that the data made it to Openfire? Is there a place to browse this in the admin interface?

I can see in the source that the data is stored using the namespace and a username… how does it know

what username to use?

Next, I try to get the data out…

SparkManager.privateDataManager.getPrivateData(key, “projectname”, new Callback(this, retrievedChosenAvatar, false));

and then in retrievedChosenAvatar I have:

protected function retrievedChosenAvatar(isMe:Boolean, chosenAvatarsIq:XMPPStanza):void {

var privateData:PrivateDataExtension = chosenAvatarsIq.getAllExtensionsByNS(“jabber:iq:private”)[0];

if (null == privateData.payload) {
return;
}

var av:data.AChosenAvatar = data.AChosenAvatar(privateData.payload);

if (null == av) {
return;
}

Unfortunately, the privateData.payload always returns null.

The stanza shows the embedded excetpion from the server side is:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

I see this in the errorCode field of the stanza… and most other fields are null.

I’m following SparkWeb and how it handles its Chat Room Bookmarks to get this far…

If all of this looks right, then the next question is: How can I set up a debugging session for openfire running on the remote server?

Thanks!

-Jim