Login/Send a Message

Okay, I found an xiff.swc binary. Next question, do I the proper setup to login and to send a message? I have found a few examples but they all include a login method, which doesn’t seem to be present in the non-Java version of the library. Has something changed for 3.0?

Here’s the code:

var msg:Message = new Message(“Hello World!”);

var connection:XMPPConnection = new XMPPConnection();

connection.useAnonymousLogin = false;

connection.username = “rbottoms”;

connection.password = “xxxxxxxxx”;

connection.server = “1.1.1.1”;

connection.connect(“flash”);

connection.send(msg);

Here is what worked for me:

public var connection:XMPPConnection;

public var chatRoom:Room;

public var roster:Roster;

connection = new XMPPConnection();

connection.username = username.text;

connection.password = password.text;

connection.server = server.text;

addMessageToChat("Username: " + connection.username + " Server: " + connection.server);

chatRoom = new Room( connection );

chatRoom.setRoomJID(roomjid.text);

chatRoom.addEventListener(RoomEvent.ROOM_JOIN, handleRoomJoin);

chatRoom.addEventListener(RoomEvent.GROUP_MESSAGE, handleGroupMessage);

chatRoom.conferenceServer = conferenceServer.text;

chatRoom.roomName = chatRoomName.text;

chatRoom.nickname = nick.text;

roster = new Roster(connection);

roomMembers.dataProvider = chatRoom.list;

connection.connect(‘flash’);

The first three lines are defined for the class, the new XMPPConnection is created on creationComplete, and roomMembers is a DataGrid component in flex. I then have a separate function to sendmessages, but it’s basically just chatRoom.sendMessage(string).

That’s getting a little closer to the mark but I am a bit confused. What I am trying to do is connect and send messages as if they were coming from a Spark client. We are building an internal system where authenticated users can receive updates about who is online and to exchange messages.

Most of the examples I’ve seen are built around the Chat Room scenario rather than swapping IM’s or other XML based info.

Hi,

can you please explain me what is room Members

roomMembers.dataProvider = chatRoom.list;

in your code…?

“roomMembers” was a Data Grid in the Flex component code.