powered by Jive Software

Send message to roster contact

First of all, Xiff ia a great library!

What xiff class should I use to send a message to my roster contact?

I should use Message.as,

But is there class that manages private conversation with Roster’'s contact as Room.as manages room chat?

// function from Room.as:

public function sendMessage( body:String, htmlBody:String ):Void

{

if( isActive() ) {

var tempMessage:Message = new Message( myContact_or_ChatRoom_or_ChatRoom/contact, msgId, body, htmlBody, Message.CHAT_TYPE );

myConnection.send( tempMessage );

}

}

// Example of XML request to Roster’'s contact

e427cdaf1bc1a29d940c852700359b721938ddc1hi there

AFAIK there is no equivalent class like Room that will do what you describe.

In your case I would simply create an instance of the Message class and populate it with the JID from the roster item, then send it via the XMPPConnection class’’ send() method.

Roster items are generic objects with the following attributes: jid, displayName, group, subscribeType, status, show, and priority. Therefore you should be able to get what you need from it to construct your message. All you really need however, is the JID.

Something like this will work for you:

var msg:Message = new Message( rosterItem.jid, null, “Hi” + rosterItem.displayName , “This is the body of the message”, Message.CHAT_TYPE );

myXMPPConnection.send( msg );