powered by Jive Software

How do I send a basic chat message?

What is the basic class required to send a message of type “chat” to another user? I have been able to log in and get the roster in my custom Flex app. I can also handle events for incoming messages. But I’'m not sure how to generate an outgoing message using XIFF.

One example I saw uses the Room.as library. It looks like that is for 3+ user chat sessions. I’'m just looking for a one-on-one example at the moment.

Just to be clear, I want to send a basic instant message, not invite the user to a multi-user chat room.

For a chat message you can you the Message class, which looks like this:

Message( recipient:String=null, msgID:String=null, msgBody:String=null, msgHTMLBody:String=null, msgType:String=null, msgSubject:String=null )

An example might look like:

var msg:Message = new Message(“bob@someserver”, null, “Hi Bob!”, “<b>Hi Bob!</b>”, Message.CHAT_TYPE, “Just saying hello!”); server.send(msg);

I hope this helps!

Thanks! That does indeed work. For what it’'s worth, you beat me by about 3 minutes. I had found the following on another thread and was on my way here to post it:

// try to send a test message to another user

var message:Message = new Message(thisItem.jid, null, “Hello world.”, null, “chat”, null);