Skip navigation
7109 Views 9 Replies Latest reply: Jun 3, 2007 11:08 AM by simba RSS
Bronze 12 posts since
May 28, 2007
Currently Being Moderated

May 29, 2007 7:02 AM

looking for a simple working XIFF 3.0 example

I''m trying to login to a Jabber server with XIFF, but I''m only getting a connect followed by a disconnect event. Is there something wrong in the following code?

 

 

trace(Security.sandboxType );

 

import org.jivesoftware.xiff.core.XMPPConnection;

 

var connection : XMPPConnection = new XMPPConnection();

connection.username = "user";

connection.password = "secret";

connection.server = "localhost";

connection.connect();

  • Bronze 54 posts since
    May 18, 2007
    Currently Being Moderated
    Jun 1, 2007 6:32 AM (in response to oli)
    Re: looking for a simple working XIFF 3.0 example

    Here is what my working code looks like:

     

            // connect to the jabber server

            public function connect( host:String, username:String, password:String ) : void {            



    try {



    connection.username = username;

    connection.password = password;

    connection.server = host;



    connection.addEventListener(LoginEvent.LOGIN, eventHandler);

    connection.addEventListener(IncomingDataEvent.INCOMING_DATA, eventHandler);

    connection.addEventListener(OutgoingDataEvent.OUTGOING_DATA, eventHandler);

    connection.addEventListener(MessageEvent.MESSAGE, onMessageHandler);



    var result:Boolean = connection.connect(''flash'');



    }
    catch (errObject:Error) {



    logger.append(logger.MESSAGETYPE_ERROR, errObject.message);

    }
    }


    // primary event handler, just logging for now
    private function eventHandler ( eventObj:Object ) : void {



    try {



    switch( eventObj.type ) {



    case "outgoingData":

    logger.append(logger.MESSAGETYPE_INFO, eventObj.type + '': '' + eventObj.data);

    break;



    case "incomingData":

    logger.append(logger.MESSAGETYPE_INFO, eventObj.type + '': '' + eventObj.data);

    break;



    case "login":

    logger.append(logger.MESSAGETYPE_INFO, eventObj.type);

    break;

    }
    }
    catch (errObject:Error) {



    logger.append(logger.MESSAGETYPE_ERROR, errObject.message);

                }               

            }            

     

     

    You may also need to add a roster to the connection:

     

    roster = new Roster(connection);

     

     

     

    You can attach event handlers to the roster and the connection for presence:

     

    connection.addEventListener(PresenceEvent.PRESENCE, thisRosterCollection.presenceEventHandler);     

    roster.addEventListener(RosterEvent.USER_ADDED, thisRosterCollection.rosterEventHandler);

     

    Message was edited by: cseibert

     

    Message was edited by: cseibert

        • Calculating status... 5 posts since
          Oct 22, 2006
          Currently Being Moderated
          Jun 2, 2007 11:04 AM (in response to oli)
          Re: looking for a simple working XIFF 3.0 example

          Oli, I don''t know if it''s a bug, I had to do exactly the same thing to get ejabberd to work with XIFF 3. I did a bit of digging and found that the  rfc''s for session initialisation in xmpp http://www.xmpp.org/rfcs/rfc3921.html#session  include the version=1.0 that is causing ejabberd to fail when XIFF talks to it. So it would appear that XIFF is complying here and ejabberd and XIFF don''t play nice together. Not technical, kind of inconclusive, but the best I have for you.

           

          Message was edited by: simba because I couldn''t figure out how the linking worked!

           

          Message was edited by: simba (again)

            • Calculating status... 5 posts since
              Oct 22, 2006
              Currently Being Moderated
              Jun 2, 2007 10:56 PM (in response to oli)
              Re: looking for a simple working XIFF 3.0 example

              That''s how I understand it, too.

               

              Now I''m coming to the conclusion that the XIFF library is neat, but 3 key problems make me consider looking at alternatives to building a jabber interface in flash/ flex:

               

              1. no SASL

              2. no TLS

               

              the above could possibly be fixed with a proxy but my view is that once you get into having to create a (python/perl) proxy to enable SASL/ TLS, you might as well do the whole thing in python/perl so I didn''t investigate that too hard.

               

              3. cross-domain sandbox security in swfs can prevent access to jabber services not hosted on the swf''s domain

               

              So as I see it, XIFF and Flash/ Flex are good if you want a sweet user interface to a jabber server located on your own network/ servers. It''s not so good if, like me, you want to create a standalone swf to interface with 3rd party or cross domain jabber servers such as google talk.

               

              I''d love to be proved wrong on any/ all of the above 3 points though.

                • Calculating status... 5 posts since
                  Oct 22, 2006
                  Currently Being Moderated
                  Jun 3, 2007 2:40 AM (in response to oli)
                  Re: looking for a simple working XIFF 3.0 example

                  thanks, that was really useful stuff.

                   

                  oli wrote:

                  1."as3xmpp supports SASL -

                   

                  I''d forgotten about this. I downloaded as3xmpp ages ago from a link on Daniel Dura''s site and must''ve got a duff version because the authentication script was incomplete (or, at least, I couldn''t make it work). As a result, I abandoned it in favour of XIFF and haven''t looked at as3xmpp again since. I''ll certainly be having another look now it''s on google code.

                   

                  oli wrote:

                  You have to use HTTP Binding (BOSH)

                   

                  ok, I didn''t know about this and shall investigate. if you''ve got any links you think would be useful, that''d be great

                   

                  oli wrote:

                  What do you mean standalone swf?

                   

                  "standalone" was a poor choice of word. All I meant was a swf hosted on a different network/ server to the jabber host. Sorry for the confusion.

                   

                  Thanks again

                   

                  Message was edited by: simba

                   

                  Message was edited by: simba (one more time!)

More Like This

  • Retrieving data ...

Bookmarked By (0)