Receiving messages

Hi! I am a little frustrated with an issue I am having with some tests I am running to be able to receive private messages. Thanks for all your help… here it is:

I am using wildfire 3.0.0 Beta.

My flash test is very simple, it logs in a user and as soon as the user is logged in it sends a message to a another user. This works fine if the message is sent from the flash client to a client like exodus (the message is received just fine by exodus). But if I try to reply to the message from exodus to the user to the Flash client the message is never delivered exodus says that the user is not available even though the session in the wildfire server is still available. Also if I run the test from Flash client to Flash client, the message is supposedly sent but it never reaches the other client (no error messages are caught by the flash clients). Now, if I send a broadcast message from wildfire, the messages are delivered successfully to as many flash clients are running.

This is my code:

import org.jivesoftware.xiff.core.XMPPConnection;

import org.jivesoftware.xiff.im.Roster;

import org.jivesoftware.xiff.data.*;

System.security.allowDomain("*");

System.security.loadPolicyFile(“http://192.168.1.4/flash/crossdomain.xml”);

// XMPPConnection

var connection = new XMPPConnection();

connection.username = “mike”;

connection.password = “mike”;

connection.server = “192.168.1.4”;

connection.resource = “xiff”;

// Event handler

eventHandler = new Object();

eventHandler.handleEvent = function( eventObj )

{

switch( eventObj.type )

{

case “outgoingData”:

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

textOutput.text += ( "\n\nSENT: " + eventObj.data );

break;

case “incomingData”:

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

textOutput.text += ( "\n\nRECEIVED: " + eventObj.data );

break;

case “login”:

var msg:Message = new Message(“gaby@mikelaptop/xiff”, null, “Hello, world.”, null, Message.NORMAL_TYPE, null);

connection.send(msg);

break;

case “message”:

trace( “Message received:” + eventObj.data );

textOutput.text += ( “\n\nMessage received:” + eventObj.data );

break;

case “presence”:

trace( “Presence received:” + eventObj.data );

textOutput.text += ( “\n\nPresence received:” + eventObj.data );

break;

case “error”:

trace( “Error received:” + eventObject.errorCode + ": " + eventObject.errorMessage );

textOutput.text += ( “\n\nError received:” + eventObject.errorCode + ": " + eventObject.errorMessage );

break;

}

}

connection.addEventListener( “outgoingData”, eventHandler );

connection.addEventListener( “incomingData”, eventHandler );

connection.addEventListener( “login”, eventHandler );

connection.addEventListener( “message”, eventHandler );

connection.addEventListener( “presence”, eventHandler );

connection.addEventListener( “error”, eventHandler );

connection.connect( “flash” );

This is the output:

SENT:

Message received:[object Object]

After a lot of hours of work I finally figured out why I was not being able to receive messages. It is simple, after you log in you must also set your own presence to available, otherwise messages will never be delivered to you. The problem is that there are different ways to set your presence and I could not found documentation or the documentation was useless.

All you have to do to get it to work is do the following on login:

case “login”:

var psce:Presence = new Presence( null, null, Presence.AVAILABLE_TYPE, Presence.SHOW_NORMAL, null, 1 );

var msg:Message = new Message(“gaby@mikelaptop”, null, “Hello, world.”, null, Message.CHAT_TYPE, null);

connection.send(psce);

connection.send(msg);

break;

After a lot of hours of work I finally figured out why I was not being able to receive messages. It is simple, after you log in you must also set your own presence to available, otherwise messages will never be delivered to you. The problem is that there are different ways to set your presence and I could not found documentation or the documentation was useless.

All you have to do to get it to work is do the following on login:

case “login”:

var psce:Presence = new Presence( null, null, Presence.AVAILABLE_TYPE, Presence.SHOW_NORMAL, null, 1 );

var msg:Message = new Message(“gaby@mikelaptop”, null, “Hello, world.”, null, Message.CHAT_TYPE, null);

connection.send(psce);

connection.send(msg);

break;