Hi folks,
I had a quick question. I’'ve gotten a flex app to compile using XIFF 3 and was able to connect to my OpenFire server and send and receive messages.
When I set my connection’‘s useAnonymous flag to true though, I get errors – Here is where I’'m getting errors:
Recieved: <stream:features><starttls xmlns=“urn:ietf:params:xml:ns:xmpp-tls” /><mechanisms xmlns=“urn:ietf:params:xml:ns:xmpp-sasl”><mechanism>DIGEST-MD5</mec hanism><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS< /mechanism><mechanism>CRAM-MD5</mechanism></mechanisms>< compression xmlns=“http://jabber.org/features/compress”><method>zlib</method></compression><auth xmlns=“http://jabber.org/features/iq-auth” /><register xmlns=“http://jabber.org/features/iq-register” /></stream:features>
Recieved: <iq type=“result” id=“log_anom_1” to=“9dc759e1@waltlap/9dc759e1”><query xmlns=“jabber:iq:auth”><resource>9dc759e1</resource></query&g t;</iq>
Error : null trapped. Resuming.
I know lots of folks are looking for a working example of how to make this thing run too – so here’'s my code – hope it works for all of you – the output goes to the debug console, but I guess you could hook it up to flex components as well.
<?xml version=“1.0” encoding=“utf-8”?>
<mx:Application xmlns:mx=“http://www.adobe.com/2006/mxml” layout=“absolute” creationComplete=“onCreationComplete()”>
<mx:Script>
<![CDATA[
import org.jivesoftware.xiff.im.Roster;
import org.jivesoftware.xiff.conference.Room;
import org.jivesoftware.xiff.events.*;
trace(Security.sandboxType );
import org.jivesoftware.xiff.core.XMPPConnection;
private var roster:Roster;
private var room:Room;
private var connection:XMPPConnection;
public function onCreationComplete():void{
var connection:XMPPConnection = new XMPPConnection();
connection.useAnonymousLogin = false;
connection.username = USERNAME;
connection.password = PASSWORD;
//I’‘m running openFire on my localhost so that’‘s what I’'ve set my server to
connection.server = “127.0.0.1”;
connection.addEventListener(ConnectionSuccessEvent.CONNECT_SUCCESS, handleConnectSuccess);
connection.addEventListener(IncomingDataEvent.INCOMING_DATA, handleIncomingData);
connection.addEventListener(OutgoingDataEvent.OUTGOING_DATA, handleOutgoingData);
connection.addEventListener(LoginEvent.LOGIN, handleServerLogin);
room = new Room(connection);
//The room I’'ve created is called test
room.setRoomJID(“test@conference.MYCOMPUTER”);
room.roomName = “test”;
room.conferenceServer = “conference.MYCOMPUTER”;
room.addEventListener(RoomEvent.ROOM_JOIN, handleRoomJoin);
roster = new Roster(connection);
connection.connect(“flash”);
}
private function handleConnectSuccess(event:ConnectionSuccessEvent):void{
trace(“Connected!”);
}
private function handleRoomJoin(event:RoomEvent):void{
room.sendMessage(“YEE HAWWW I’'M SENDING MESSAGES”);
}
private function handleServerLogin(event:LoginEvent):void{
trace(“Login event recieved”);
roster.setPresence(null, “Online”, 5);
room.join();
}
private function handleIncomingData(event:IncomingDataEvent):void{
trace("Recieved: " + event.data);
}
private function handleOutgoingData(event:OutgoingDataEvent):void{
trace("Sent: " + event.data);
}
]]>
</mx:Script>
</mx:Application>
Good luck,
Walt Schlender
weblog: www.dice.cx - business, computers, food
bLine Creations - An Interactive Internet Company
–Referrals are the life’'s blood of my business.
If you or anyone you know needs a developer,
please contact me!
Message was edited by: wongalongtong
Message was edited by: wongalongtong