powered by Jive Software

How to configure server so that client can request remotely (Like XIFFIAN)

Hi,

I designed a simple web client so that any one can sign in and chat in a group.

But now the problem is I m host the SWF and a simple html page in my server(Windows 2003 server) IIS 6.0. Jabber Server 2.6.1 also installed in my server. So in my fla file I give the server name “196.35.231.26” it’'s my server real IP.

I m simply install Jabber Server and configure nothing except language/server name etc…

But when a client request for the page server sends the page to client end but login request or add new user request cann’'t be done…

Here is code(Action Script) snippet…Please help me

I m using Macromedia Flash 8.0

Login Screen: Scene 1, Frame 1


System.security.allowDomain("*");

System.security.loadPolicyFile(“http://196.35.231.26/webchat/crossdomain.xml”);

//load the cookie

var cookie = SharedObject.getLocal(“login”);

if (cookie.data.version == null )

{

//Default

}

else

{

}

var strUserName:String = “”;

var strUserPassword:String = “”;

var strErrorCode:String = “”;

lblErrorCode.text = strErrorCode;

var globalHandler = new Object();

stop();

There is a login button if the button is pressed then it will go to the frame 2


Scene 1: Frame 2: It shows an animation that “please wait while connecting”


import org.jivesoftware.xiff.core.XMPPConnection;

import org.jivesoftware.xiff.conference.InviteListener;

var connection;

var dureeTimeOut=10000;

connection = new XMPPConnection();

var timerTest;

function endTimer()

{

if(connection.isActive())

{

//trace(“Connected”);

clearInterval(timerTest);

}

if(connection.isLoggedIn())

{

clearInterval(timerTest);

gotoAndPlay(“Scene 1”,3);

}

}

//Stage.scaleMode = “noScale”; //could be showAll…

//Stage.align = “TL”; //Top Left

globalHandler.handleEvent = function(eventObj)

{

switch (eventObj.type)

{

case “error”:

lblErrorCode.text = “Invalid User”;

gotoAndPlay(“Scene 1”,1);

break;

case “login” :

trace(“Login invoked”);

gotoAndStop(“Scene 1”,6);

break;

case “connection” :

break;

}

}

connection.username = strUserName;

connection.password = strUserPassword;

connection.server = “196.35.231.26”;

connection.port = 5222;

connection.resource = “XIFF”;

timerTest = setInterval(endTimer,500); //Retry every half second

connection.connect( “flash” );

connection.addEventListener(“login”, globalHandler);

connection.addEventListener(“connection”, globalHandler);

connection.addEventListener(“error”, globalHandler);

Stage.addListener( globalHandler );

stop();


Scene 1: Frame 6: Prompt the user to enter a nick to enter room name “testRoom”


import org.jivesoftware.xiff.conference.Room;

import org.jivesoftware.xiff.im.Roster;

var bFrameAcive:Boolean = true;

var myRoster:Roster = new Roster(connection);

var chatRoom = new Room( connection );

var spaceCountNick:Number = 0;

var scrollTestNick;

var strNick:String = “”;

var timeDuration:Number = 10000;

var timerTest;

function endTimer()

{

btnNick.enabled = true;

lblNickStatus.text = “”;

lblNickStatus.text = “An Error Occured!!”;

clearInterval(timerTest);

clearInterval(scrollTestNick);

lblNickScroll.text = “”;

}

function scrollTimerNick()

{

var strScrollNick:String = “”;

spaceCountNick = (spaceCountNick+1)%30;

for( var i = 0; i<spaceCountNick; i++)

{

strScrollNick += " ";

}

strScrollNick += “Validating”;

lblNickScroll.text = strScrollNick;

//trace(“Timer Runing”);

}

//var globalHandler = new Object();

globalHandler.handleEvent = function( eventObj )

{

trace("Which event occur: " +eventObj.type);

switch( eventObj.type )

{

case “nickConflict”:

trace(“Nick Conflict Invocked”)

spaceCountNick = 0;

clearInterval(scrollTestnick);

lblNickStatus.text = “”;

lblNickStatus.text = “An error is occured…”;

lblNickScroll.text = “”;

btnNick.enabled = true;

break;

case “roomJoin” : // When user try to join a room this event will be invocked

trace(“roomJoin Invocked”);

myRoster.setPresence(null, “Online”, 5);

clearInterval(scrollTestnick);

lblNickScroll.text = “”;

gotoAndPlay(“Scene 1”,10);

break;

case “userJoin”:

//trace(“User Join Invocked”);

clearInterval(timerTest);

clearInterval(scrollTestNick);

myRoster.setPresence(null, “Online”, 5);

lblNickStatus.text = “”;

lblNickScroll.text = “”;

bFrameActive = false;

gotoAndPlay(“Scene 1”,10);

break;

case “error”:

trace(“Error when nick registering”);

spaceCountNick = 0;

clearInterval(scrollTestnick);

lblNickStatus.text = “”;

lblNickStatus.text = “An error is occured…”;

lblNickScroll.text = “”;

btnNick.enabled = true;

break;

}

}

globalHandler.enterButtonClicked = function()

{

//trace(“enterButtonClicked”);

lblNickStatus.text = “”;

strNick = txtNickName.text;

var nickLen = strNick.length;

if(nickLen == 0)

{

lblNickStatus.text = “”;

lblNickStatus.text = “Nick is must…”;

return;

}

spaceCountNick = 0;

// Room - Enter the chat room with the given nickname

chatRoom.roomName = “testRoom”;

chatRoom.nickname = strNick;

chatRoom.conferenceServer = “conference.196.35.231.50”;

var stat:Boolean = false;

stat = chatRoom.join();

timerTest = setInterval(endTimer,timeDuration);

//trace("Nick Status: "+stat.toString());

scrollTestNick = setInterval(scrollTimerNick,100);

btnNick.enabled = false;

//trace(“chatRoom.join() invocked”);

}

// Keyboard listener

var enterKeyListener = new Object();

enterKeyListener.onKeyUp = function()

{

if( Key.getCode() == Key.ENTER && bFrameActive )

{

globalHandler.enterButtonClicked();

}

}

// We assume by this time client will not take 30 minutes time and connection is still alive

// So that we don’'t add any listener to the connection object

chatRoom.addEventListener( “nickConflict”, globalHandler );

chatRoom.addEventListener( “roomJoin”, globalHandler );

chatRoom.addEventListener( “userJoin”, globalHandler );

//connection.addEventListener( “error” , globalHandler );

btnNick.addEventListener( “click”, globalHandler.enterButtonClicked );

Key.addListener( enterKeyListener );

Stage.addListener( globalHandler );

stop();


Scene 1: Frame 10: Group Chat window (exactly that I found from jivesoftware.org example)


import org.jivesoftware.xiff.core.XMPPConnection;

import org.jivesoftware.xiff.conference.Room;

import org.jivesoftware.xiff.im.Roster;

Stage.scaleMode = “noScale”;

Stage.align = “TL”;

var curDepth = 10;

var margin = 10;

var userColor = “#0000FF”;

var serverColor = “#006600”;

var otherColor = “#000000”;

// Attach the text area used for chat output

this.attachMovie( “TextArea”, “chatOutputWindow”, curDepth++ );

// Attach the grid used for the room roster

this.attachMovie( “DataGrid”, “chatRoster”, curDepth++ );

chatRoster.dataProvider = chatRoom;

// Attach the input text

this.attachMovie( “TextInput”, “chatInput”, curDepth++ );

chatOutputWindow.editable = false;

chatOutputWindow.html = true;

// Attach the button

this.attachMovie( “Button”, “sendButton”, curDepth++ );

sendButton.label = “Send”;

function positionAndSizeGUI()

{

// Resize and position the UI items

chatInput.setSize( (2Stage.width)/3 - 3margin, 25 );

chatInput._x = margin;

chatInput._y = Stage.height - chatInput._height - margin;

sendButton.setSize( Stage.width/3, 25 );

sendButton._x = chatInput._x + chatInput._width + margin;

sendButton._y = chatInput._y;

chatOutputWindow._x = margin;

chatOutputWindow._y = margin;

chatOutputWindow.setSize( (2Stage.width)/3 - 3margin, Stage.height - 3*margin - chatInput._height );

chatRoster._x = chatOutputWindow._x + chatOutputWindow._width + margin;

chatRoster._y = margin;

chatRoster.setSize( Stage.width/3, Stage.height - (Stage.height - sendButton._y) - 2*margin );

}

// Event handler

//var globalHandler2 = new Object();

globalHandler.handleEvent = function( eventObj )

{

switch( eventObj.type )

{

case “outgoingData”:

trace( "SENT: " + eventObj.data );

break;

case “incomingData”:

trace( "RECEIVED: " + eventObj.data );

break;

case “login”:

break;

case “groupMessage”:

var msg = eventObj.data;

var nick = msg.from.split( “/” )[1];

addToChatOutput( nick, msg.body );

break;

}

}

globalHandler.sendButtonClicked = function()

{

sendMessage( chatInput.text );

chatInput.text = “”;

}

globalHandler2.onResize = positionAndSizeGUI;

// Keyboard listener

var keyListener = new Object();

keyListener.onKeyUp = function()

{

if( eval( Selection.getFocus() ) == chatInput.label && Key.getCode() == Key.ENTER && !bFrameActive )

{

// Mimic send button click

globalHandler.sendButtonClicked();

}

}

// Listener setup

connection.addEventListener( “outgoingData”, globalHandler );

connection.addEventListener( “incomingData”, globalHandler );

chatRoom.addEventListener( “groupMessage”, globalHandler );

//connection.addEventListener( “login”, globalHandler );

sendButton.addEventListener( “click”, globalHandler.sendButtonClicked );

Key.addListener( keyListener );

Stage.addListener( globalHandler );

function addToChatOutput( nickname, text )

{

if( nickname == chatRoom.nickname )

{

var output = “” + nickname + ": ";
}
else if( nickname == null )
{
var output = "* ";
}
else
{
var output = “” + nickname + ": ";
}

output += text + “
”;

chatOutputWindow.text += output;

}

function sendMessage( messageBody )

{

chatRoom.sendMessage( messageBody );

}

positionAndSizeGUI();

//connection.connect( “flash” );

stop();


Scene 1: Frame 14: Adding new user, there is a button on first frame name “new user” if clicked here control will go here


import org.jivesoftware.xiff.core.XMPPConnection;

var connection;

var dureeTimeOut=15000;

var timerConnexion;

var spaceCount:Number = 0;

connection = new XMPPConnection();

connection.username = null;

connection.server = “196.35.231.26”;

var regInfo = new Object();

var timerTest;

var scrollTest;

function scrollTimer()

{

spaceCount = (spaceCount+1)%40;

var strScroll:String = “”;

for( var i = 0; i<spaceCount; i++)

{

strScroll += " ";

}

strScroll += “Connecting and validating”;

lblScroll.text = strScroll;

}

function endTimer()

{

if(connection.isActive())

{

clearInterval(timerTest);

}

}

//Stage.scaleMode = “noScale”; //could be showAll…

//Stage.align = “TL”;

var eventHandler = new Object();

eventHandler.submitButtonClicked = function()

{

lblRegStatus.text = “”;

var username:String = usernameBox.text;

var password:String = password1.text;

var _password2:String = password2.text;

var email:String = emailBox.text;

var name:String = name1.text;

var age:String = ageBox.text

var namelen:Number = username.length;

var passlen:Number = password.length;

if(namelen == 0)

{

lblRegStatus.text = “”;

lblRegStatus.text = “User Name Can’'t be NULL”;

return;

}

if(password != _password2 || passlen == 0)

{

lblRegStatus.text = “”;

lblRegStatus.text = “Password not Match!”;

return;

}

connection.username = null

connection.server = “196.35.231.26”;

connection.port = 5222;

connection.resource = “XIFF”;

timerTest = setInterval(endTimer,500); //Retry every half second

connection.connect( “flash” );

regInfo = ;

spaceCount = 0;

scrollTest = setInterval(scrollTimer,100);

lblScroll.text = “Connecting user…”;

btnSubmit.enabled = false;

connection.getRegistrationFields();

}

eventHandler.backButtonClicked = function()

{

connection.disconnect();

spaceCount = 0;

clearInterval(scrollTest);

lblScroll.text = “”;

gotoAndPlay(“Scene 1”,1);

}

eventHandler.handleEvent = function(eventObj)

{

switch (eventObj.type)

{

case “registrationSuccess”:

lblRegStatus.text = “”;

lblRegStatus.text = “Registration Successeced”;

spaceCount = 0;

clearInterval(scrollTest);

lblScroll.text = “”;

connection.disconnect();

gotoAndPlay(“Scene 1” , 18);

break;

case “registrationFields” :

connection.sendRegistrationFields(regInfo);

break;

case “error”: // Opens an error popup. If contains error code, we display it - else, we use a generic message… Could be better made!

lblRegStatus.text = “”;

lblRegStatus.text = “Can’'t be registered!!”;

spaceCount = 0;

clearInterval(scrollTest);

lblScroll.text = “”;

btnSubmit.enabled = true;

break;

}

}

connection.addEventListener( “error”, eventHandler);

connection.addEventListener( “connection”, eventHandler);

connection.addEventListener( “registrationFields”, eventHandler);

connection.addEventListener( “registrationSuccess”, eventHandler);

btnBack.addEventListener( “click”, eventHandler.backButtonClicked );

btnSubmit.addEventListener( “click”, eventHandler.submitButtonClicked );

Stage.addListener( eventHandler );

stop();


Please,please,please help me…should I configure anything in Server or need 2 change my code

I m really frustured…

Waiting for ur kind reply…

Regards,

Aakaash

aakaashinfo@yahoo.com