Skip navigation
3560 Views 1 Reply Latest reply: Sep 10, 2007 7:49 AM by Vivian RSS
Bronze 20 posts since
Sep 9, 2007
Currently Being Moderated

Sep 9, 2007 5:21 PM

XIFF3 and Flex using OpenFire localhost

Hi,

 

I am made  a swc from the beta version of XIFF3 and I tried to make a simple chat client on OpenFire in  my PC:

 

 

 

I am not able to login with the following code..

 

 

 

 

 

 

 

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="initApp()" layout="horizontal" viewSourceURL="srcview/index.html">

<mx:Script>

<![CDATA[

import org.igniterealtime.xiff.core.XMPPConnection;

import org.igniterealtime.xiff.conference.Room;

import org.igniterealtime.xiff.im.Roster;

import org.igniterealtime.xiff.events.LoginEvent;

import org.igniterealtime.xiff.data.*;

 

 

 

// you will need to set these

var SERVER = "localhost";

var CHATROOM = "flashroom";

 

 

 

var chatRoom:Room;

var connection:XMPPConnection;

 

function initApp()

{

connection = new XMPPConnection();

//connection.addEventListener("error",this);

connection.addEventListener(LoginEvent.LOGIN, doLogin);

connection.addEventListener("disconnection", disconnection);

 

}

 

function doLogin()

{

if( !connection.isLoggedIn() )

{

connection.username = "tendency";

connection.password = "cake1";

connection.server = SERVER;

connection.connect("flash");

if(connection.isLoggedIn()){

debugTxt.text = "Login attempted";

}                   

}

else

{

connection.disconnect();

debugTxt.text = "disconnected";

}

}

 

function outgoingData(event)

{

debugTxt.text += "OUTGOING: " + event.data + " \n ";

}

 

function incomingData(event)

{

debugTxt.text += "INCOMING: " + event.data + " \n ";

}

 

function login(event)

{

loginBtn.label = "Logout";

chatInput.enabled = true;

sendButton.enabled = true;

 

var myRoster:Roster = new Roster(connection);

myRoster.setPresence(null, "Online", 5);

 

// Room - CHANGE THESE SETTINGS

chatRoom = new Room( connection );

chatRoom.roomName = CHATROOM;

chatRoom.nickname = connection.username;

chatRoom.conferenceServer = "conference."+SERVER;           

 

chatRoom.join();

//chatRoster.addChild(connection.username.);

 

//chatRoster.addItem( connection.username );

 

}

 

function groupMessage(event)

{

displayUserMessage( getNickFromJID(event.data.from) , event.data.body );

}

 

 

 

 

function disconnection()

{

chatInput.enabled = false;

chatOutboundWindow.htmlText = "";

sendButton.enabled = false;

//chatRoster.removeChild(connection.username);

//chatRoster.removeAll();

}

 

function displayUserMessage(user:String, message:String):void

{

var fontColor = ( user == chatRoom.nickname ) ? "#009900" : "#0000FF";

chatOutboundWindow.htmlText="<font color='"fontColor"'><b>"user":</b> "message+"</font><br />";

}

 

function sendMsg():void

{

if (chatInput.text!="")

{

chatRoom.sendMessage(chatInput.text);

chatInput.text="";

}

}

 

function getNickFromJID( jid:String ):String

{

return jid.split("/")[1];

}

]]>

 

 

 

 

 

 

 

Can someone help me please.. I need to get this done at the earliest.

 

 

 

thanks in advance

 

 

 

Vi

More Like This

  • Retrieving data ...

Bookmarked By (0)